-
Notifications
You must be signed in to change notification settings - Fork 4k
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
ECS: TaskDefinition Container Secret property #3326
Labels
needs-triage
This issue or PR still needs to be triaged.
Comments
Here is a working override in the meantime, using an RDS instance secret as an example: const database = new DatabaseInstance(this, 'rds', {
vpc,
engine: DatabaseInstanceEngine.MYSQL,
instanceClass: InstanceType.of(InstanceClass.BURSTABLE2, InstanceSize.MICRO),
databaseName: DATABASE_NAME,
masterUsername: DATABASE_ADMIN,
});
database.connections.allowDefaultPortFromAnyIpv4();
const taskDefinition = new TaskDefinition(this, 'task', {
compatibility: Compatibility.EC2,
});
const container = taskDefinition.addContainer('container', {
image: ContainerImage.fromEcrRepository(new Repository(this, 'ecr', {}), 'latest'),
});
{
database.secret && database.secret.grantRead(taskDefinition.obtainExecutionRole());
const taskDefinitionResource = taskDefinition.node.findChild('Resource') as unknown as CfnTaskDefinition;
taskDefinitionResource.addPropertyOverride('ContainerDefinitions.0.Secrets', [{
Name: 'RDS_SECRET',
ValueFrom: database.secret && database.secret.secretArn
}]);
} |
You can also use Secrets like this const taskDef = new cdk.CfnResource(this, 'TaskDef', {
type: 'AWS::ECS::TaskDefinition',
properties: {
...
ContainerDefinitions : [
{
...
Secrets: {
Name: '',
ValueFrom: 'secret-arn',
}
...
},
],
...
},
}); |
Duplicate of #1478 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: for support questions, please first reference our documentation, then use Stackoverflow. This repository's issues are intended for feature requests and bug reports.
I'm submitting a ...
What is the current behavior?
If the current behavior is a 🪲bug🪲: Please provide the steps to reproduce
There is currently no practical way to securely pass SSM parameters or Secrets Manager secrets to an ECS task definition, due to the missing AWS::ECS::TaskDefinition ClontainerDefinition Secret property.
What is the expected behavior (or behavior of feature suggested)?
Add a
secrets
property oraddSecrets
method, to provide parameters and secrets to ECS tasks. Ideally, the secrets given would also be added to the container role policy.What is the motivation / use case for changing the behavior or adding this feature?
Securely and easily pass parameters and secrets to containers
Please tell us about your environment:
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)
The text was updated successfully, but these errors were encountered: