AWS CDK: How to configure the parameters property for a SSM Assocation?

My goal is to use the AWS Systems Manager State Manager to run a cron job that will shut down an RDS instance at 9PM. I'm in the process of building out the CloudFormation template using the AWS CDK.

The AWS CDK documentation for the CfnAssociation construct mentions the parameters property. It has a type of any. I'm trying to find an example of how to use the property.

Please help me to understand how to correctly add the parameter AutomationAssumeRole using this code snippet. AutomationAssumeRole expects the ARN for the role. For example, arn:aws:iam::12345678999:role/StopStartRebootRDS.

// Create the State Manager association that will shut down an RDS instance.
new ssm.CfnAssociation(this, 'StopRdsInstanceAssociation', {
  name: 'AWS-StopRdsInstance', // The document name to use.
  associationName: 'StopRdsInstance', // A user friendly name for this association.
  documentVersion: '$DEFAULT', // I'm guessing this will work. Not sure yet.
  instanceId: dbInstance.instanceIdentifier, // The RDS database that will be shut down.
  scheduleExpression: '0 00 21 ? * * *', // Daily at 9PM.
  parameters: {}, // What does this look like?
});

Your guidance is appreciated.

What I've tried

I thought I could create an SSM parameter and populate it with the Role ARN. But this is just wrong. I'm not sure how else to set this up. The error from this configuration is below.

const automationAssumeRole = new ssm.CfnParameter(this, 'RdsParameter', {
  type: 'String',
  value: role.roleArn,
});

// Create the State Manager association that will 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..



Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)