2 Answers
- Newest
- Most votes
- Most comments
1
I had implemented something similar using EventBridge to trigger a StepFunction for task restart , you can do something similar
Refer to my blog post
const secretName = 'my-secret'; // Replace with your secret name
const rule = new events.Rule(this, 'SecretRotationRule', {
ruleName: 'SecretRotationRule-' + secretName,
eventPattern: {
source: ['aws.secretsmanager'],
detailType: ['AWS API Call via CloudTrail'],
detail: {
eventSource: ['secretsmanager.amazonaws.com'],
eventName: ['RotateSecret'],
requestParameters: {
secretId: [secretName],
},
},
},
});
rule.addTarget(new targets.SfnStateMachine(stateMachineL2));
0
Have you considered using Amazon EventBridge to automate the restart of your ECS service when the secret is rotated?
With EventBridge, you can listen for "RotateSecret" events from Secrets Manager and trigger an ECS service update, ensuring your containers always load the latest credentials.
answered 2 years ago
Relevant content
asked 2 years ago
asked 2 years ago

I agree with this! This was the EventBridge rule I created:
I had this event trigger a Lambda function that would use the boto3 client in Python to update the service (see the Lambda source code here: https://github.com/epilogue-club/terraform-aws-ecs-secret-rotation/blob/main/lambda/main.py)