-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "secrets" support for ECS Task Container Definitions #6503
Comments
The |
@gazoakley My hypothesis is that Terraform does not detect the key 'secrets' in the container definition json. Evidence:
|
@starpebble: Apologies - it does unmarshal it. On the plus side, I think you'll find this works automagically in the next version of the provider 😃(that whole JSON structure is unmarshalled based on the structures defined in |
@gazoakley - This is good news. I will double check. v1.46.0 will be available soon. I can verify whether the new provider supports ecs container secrets. I may build the provider myself and install it locally, too. |
This has been released in version 1.46.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
My terraform managed ecs container will use secrets now, with aws provider v1.46. Great! thx u @gazoakley @bflad @mbfrahry N.B. There is an aws problem with out of date ecs agents on ec2 hosts. My cluster reported errors about missing attributes when the cluster launched my tasks with container secrets:
I updated my agent with sudo yum update -y ecs-init, sudo service docker restart && sudo start ecs, on an amz linux host with ssm:
|
This still isn't supported by v1.46.0. I get the following error using
I think |
@gcoop: That's the documentation for the data source. The resource docs are here: https://www.terraform.io/docs/providers/aws/r/ecs_task_definition.html#execution_role_arn |
@gcoop I have seen this throw the same error when |
@gcoop are you still running into issues? Also, which region were you using? |
I am still facing this issue in Adding
I tried setting I tried a 2-step apply approach as well - adding the role then the secrets - for both methods, but to no avail. edit: Realised later that task_role_arn is the role for the task, whereas executionRoleArn is what the ecs-agent uses, and thus needs to be able to pass the secrets as ENV variables to the docker daemon. edit (solved): I had to specify my
|
No longer facing the issue my end @rlopezro . |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Community Note
Description
Please add support for "secrets"
An AwsEcsContainerDefinition data source should support defining container secrets. So should a terraform "aws_ecs_task_definition" resource.
A ecs task container may define "secrets", docs for the Task Definition Parameters.
New or Affected Resource(s)
aws_ecs_task_definition resource and data source, the container_definitions attribute
Potential Terraform Configuration
Example: the ssm parameter db.password should be passed to the container definition. The container definition will have a "secrets" section that is non-null.
resource "aws_ecs_task_definition" "service-api" {
family = "service-api"
container_definitions = <<DEFINITION
[
{
"essential": true,
"image": "aaa.dkr.ecr.us-east-1.amazonaws.com/service:latest",
"memory": 3072,
"memoryReservation": 2048,
"name": "service-api",
"portMappings": [
{
"containerPort": 80,
"hostPort": 0
}
],
"dockerLabels" : {
"project": "terraform-security-improvements",
},
"environment" : [
{
"name": "AN_ENV_KEY",
"value": "some environment variable"
}
],
"secrets" : [
{
"name": "DB_PASSWORD",
"valueFrom": "dev.db.password"
}
]
}
]
DEFINITION
}
References
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html
The text was updated successfully, but these errors were encountered: