2

I'm wondering if creating SSM documents via CloudFormation actually makes sense or if instead I should use another mechanism.

My concern is, that when the content changes, CloudFormation actually creates a new document and destroys the old one. In that process also the name of the document changes. The name cannot be hardcoded or CloudFormation complains with:

CloudFormation cannot update a stack when a custom-named resource requires replacing

With permanently changing names its going to be impossible to reference the document anywhere.

I haven't seen a possibility to create a new document version via CFN, as I can do manually in the AWS console.

What's best practice here?

I know I can create a custom CFN resource and deal with the document update in a lambda. But ain't there a simple solution?

udondan
  • 57,263
  • 20
  • 190
  • 175
  • I found a feature request for updating the document instead of replacing it. https://github.com/aws-cloudformation/aws-cloudformation-coverage-roadmap/issues/339 - I guess that sums it up. In it's current form, CFN seems to be unsuitable for managing documents. – udondan Mar 08 '20 at 09:51
  • Usually you don't manually specify a name and then query the stack outputs for the name. You can also write the name to SSM parameter or something like that to make it easier. – kichik Mar 09 '20 at 18:03
  • 2
    I just published my custom resource to manage SSM documents. It's made for CDK but I added documentation how to use it in plain old CloudFormation as well - https://github.com/udondan/cdk-ssm-document – udondan Mar 14 '20 at 15:30

1 Answers1

2

The challenge you describe has, I think, been solved or mitigated by the (recently released?) UpdateMethod property for AWS::SSM::Document. Now, you can specify NewVersion for that property, and that will create a new version of the same document and set it as the default version.

See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ssm-document.html#cfn-ssm-document-updatemethod

Paul
  • 53
  • 4