I am working on utilizing the AWS Systems Manager State Manager to automate shutting down an RDS instance at 9PM using a cron job. Currently, I am constructing the CloudFormation template with the help of AWS CDK.
While going through the AWS CDK documentation for the CfnAssociation construct, I came across the parameters
property which has a type of any
. I am looking for a sample on how to effectively utilize this property.
I need assistance in properly adding the parameter AutomationAssumeRole
by following this code snippet. The AutomationAssumeRole
requires the ARN for the role, such as
arn:aws:iam::12345678999:role/StopStartRebootRDS
.
// Setting up the State Manager association to shut down an RDS instance.
new ssm.CfnAssociation(this, 'StopRdsInstanceAssociation', {
name: 'AWS-StopRdsInstance',
associationName: 'StopRdsInstance',
documentVersion: '$DEFAULT',
instanceId: dbInstance.instanceIdentifier,
scheduleExpression: '0 00 21 ? * * *',
parameters: {}, // How should this be configured?
});
Your advice would be greatly appreciated.
My Attempts
Initially, I attempted to create an SSM parameter and store the Role ARN inside it. However, I realized that this approach was incorrect. I am unsure about the correct way to set this up. The error message resulting from this configuration is provided below.
const automationAssumeRole = new ssm.CfnParameter(this, 'RdsParameter', {
type: 'String',
value: role.roleArn,
});
// Setting up the State Manager association to shut down an RDS instance.
new ssm.CfnAssociation(this, 'StopRdsInstanceAssociation', {
name: 'AWS-StopRdsInstance',
associationName: 'StopRdsInstance',
documentVersion: '$DEFAULT',
instanceId: dbInstance.instanceIdentifier,
scheduleExpression: '0 00 21 ? * * *',
parameters: {
automationAssumeRole,
},
});
Error: Resolution error: Resolution error: Trying to resolve() a Construct at /Resources/${Token[InfrastructureDev.RdsStack.StopRdsInstanceAssociation.LogicalID.762]}/Properties/parameters/automationAssumeRole/node..