{"action":"created","issue":{"url":"https://api.github.com/repos/aws/amazon-ecs-agent/issues/791","repository_url":"https://api.github.com/repos/aws/amazon-ecs-agent","labels_url":"https://api.github.com/repos/aws/amazon-ecs-agent/issues/791/labels{/name}","comments_url":"https://api.github.com/repos/aws/amazon-ecs-agent/issues/791/comments","events_url":"https://api.github.com/repos/aws/amazon-ecs-agent/issues/791/events","html_url":"https://github.com/aws/amazon-ecs-agent/issues/791","id":226396864,"node_id":"MDU6SXNzdWUyMjYzOTY4NjQ=","number":791,"title":"Allow environment variables in awslogs-group","user":{"login":"kinghajj","id":3409,"node_id":"MDQ6VXNlcjM0MDk=","avatar_url":"https://avatars0.githubusercontent.com/u/3409?v=4","gravatar_id":"","url":"https://api.github.com/users/kinghajj","html_url":"https://github.com/kinghajj","followers_url":"https://api.github.com/users/kinghajj/followers","following_url":"https://api.github.com/users/kinghajj/following{/other_user}","gists_url":"https://api.github.com/users/kinghajj/gists{/gist_id}","starred_url":"https://api.github.com/users/kinghajj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinghajj/subscriptions","organizations_url":"https://api.github.com/users/kinghajj/orgs","repos_url":"https://api.github.com/users/kinghajj/repos","events_url":"https://api.github.com/users/kinghajj/events{/privacy}","received_events_url":"https://api.github.com/users/kinghajj/received_events","type":"User","site_admin":false},"labels":[{"id":231351362,"node_id":"MDU6TGFiZWwyMzEzNTEzNjI=","url":"https://api.github.com/repos/aws/amazon-ecs-agent/labels/kind/feature%20request","name":"kind/feature request","color":"209daa","default":false},{"id":593669626,"node_id":"MDU6TGFiZWw1OTM2Njk2MjY=","url":"https://api.github.com/repos/aws/amazon-ecs-agent/labels/scope/ECS%20Service","name":"scope/ECS Service","color":"c5def5","default":false},{"id":637836619,"node_id":"MDU6TGFiZWw2Mzc4MzY2MTk=","url":"https://api.github.com/repos/aws/amazon-ecs-agent/labels/scope/Monitoring","name":"scope/Monitoring","color":"c5def5","default":false},{"id":637829171,"node_id":"MDU6TGFiZWw2Mzc4MjkxNzE=","url":"https://api.github.com/repos/aws/amazon-ecs-agent/labels/scope/Task%20Definition","name":"scope/Task Definition","color":"c5def5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2017-05-04T20:19:54Z","updated_at":"2019-06-04T12:35:08Z","closed_at":null,"author_association":"NONE","body":"At my company, we use multicontainer ElasticBeanstalk tiers for all of our environments. Currently we stream logs to SumoLogic via their agent; but, for our needs, CloudWatch logs would be sufficient and much cheaper. Each of our environments defines an environment variable \"ENVIRONMENT\", with values like \"develop\", \"qa\", etc. I found that recent ECS agents support streaming logs to CloudWatch natively via the awslogs driver. I attempted to do something like this:\r\n\r\n    {\r\n      \"name\": \"tasks\",\r\n      \"image\": \"876270261134.dkr.ecr.us-west-2.amazonaws.com/armada/tasks:{{ BUILD_TAG }}\",\r\n      \"readonlyRootFilesystem\": true,\r\n      \"essential\": true,\r\n      \"memory\": 3072,\r\n      \"workingDirectory\": \"/armada/app\",\r\n      \"command\": [\r\n        \"./start.sh\"\r\n      ],\r\n      \"portMappings\": [\r\n        {\r\n          \"hostPort\": 80,\r\n          \"containerPort\": 80\r\n        }\r\n      ],\r\n      \"logConfiguration\": {\r\n        \"logDriver\": \"awslogs\",\r\n        \"options\": {\r\n          \"awslogs-group\": \"/armada/$ENVIRONMENT/tasks.log\",\r\n          \"awslogs-region\": \"us-west-2\"\r\n        }\r\n      }\r\n\r\nSome background: when our CI system produces a build, it instantiates the Dockerrun.aws.json from a template defined in our source repository. `BUILD_TAG` is `${branch}-${build_number}-${commit_hash_prefix}`. The CI system produces ZIP archives for the web and worker tiers, uploads them to S3, and registers them as application versions which can be reused against any of the other environments via a Slack bot (`@bula deploy develop develop-38-abcd1234`).\r\n\r\nI don't want to hardcode `\"awslogs-group\": \"/armada/tasks.log\"`, because then all environments' logs would be grouped the same. When I attempted this, however, I got an error `CannotStartContainerError: API error (500): Failed to initialize logging driver: InvalidParameterException: 1 validation error detected: Value '\\''/armada/$ENVIRONMENT/tasks.log'\\'' at '\\''logGroupName'\\'' failed to satisfy constraint: Member must satisfy regular ex`.\r\n\r\nThe only workaround I can think of would be to alter our CI system to not register application versions at build time, but just ZIP archives with Dockerrun.aws.json still in Jinja2 template form; and, in tandem, alter the deployment bot to download that, extract it, instantiate the Dockerrun.aws.json template with the target environment, and register a new application version, and update the target environment with it. That seems needlessly convoluted (and, frankly, ugly) to me. If there's some other, cleaner way to accomplish this, I'm open to any suggestions. But IMHO, it'd be quite nice to use environment variables in task definitions, to keep them easily reusable."},"comment":{"url":"https://api.github.com/repos/aws/amazon-ecs-agent/issues/comments/498652395","html_url":"https://github.com/aws/amazon-ecs-agent/issues/791#issuecomment-498652395","issue_url":"https://api.github.com/repos/aws/amazon-ecs-agent/issues/791","id":498652395,"node_id":"MDEyOklzc3VlQ29tbWVudDQ5ODY1MjM5NQ==","user":{"login":"bsalgautam16","id":5147425,"node_id":"MDQ6VXNlcjUxNDc0MjU=","avatar_url":"https://avatars2.githubusercontent.com/u/5147425?v=4","gravatar_id":"","url":"https://api.github.com/users/bsalgautam16","html_url":"https://github.com/bsalgautam16","followers_url":"https://api.github.com/users/bsalgautam16/followers","following_url":"https://api.github.com/users/bsalgautam16/following{/other_user}","gists_url":"https://api.github.com/users/bsalgautam16/gists{/gist_id}","starred_url":"https://api.github.com/users/bsalgautam16/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsalgautam16/subscriptions","organizations_url":"https://api.github.com/users/bsalgautam16/orgs","repos_url":"https://api.github.com/users/bsalgautam16/repos","events_url":"https://api.github.com/users/bsalgautam16/events{/privacy}","received_events_url":"https://api.github.com/users/bsalgautam16/received_events","type":"User","site_admin":false},"created_at":"2019-06-04T12:35:08Z","updated_at":"2019-06-04T12:35:08Z","author_association":"NONE","body":"I'm still looking for this option."}}
{"actor":{"display_login":"bsalgautam16"}}