<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>The Wombelix Post - CloudFormation</title><link href="https://dominik.wombacher.cc/" rel="alternate"/><link href="/feeds/tag_cloudformation.atom.xml" rel="self"/><id>https://dominik.wombacher.cc/</id><updated>2024-07-17T00:00:00+02:00</updated><entry><title>AWS CloudFormation and CDK doesn't support AWS SSM Parameter Store SecureString?!</title><link href="https://dominik.wombacher.cc/posts/aws-cloudformation-and-cdk-doesnt-support-aws-ssm-parameter-store-securestring.html" rel="alternate"/><published>2024-05-12T00:00:00+02:00</published><updated>2024-07-17T00:00:00+02:00</updated><author><name>Dominik Wombacher</name></author><id>tag:dominik.wombacher.cc,2024-05-12:/posts/aws-cloudformation-and-cdk-doesnt-support-aws-ssm-parameter-store-securestring.html</id><summary type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;I recently started to set up some resources on AWS for my side projects.
For starters an AWS KMS key so I can encrypt data on S3 and in the  ... &lt;a class="read-more" href="/posts/aws-cloudformation-and-cdk-doesnt-support-aws-ssm-parameter-store-securestring.html"&gt; [read more]&lt;/a&gt;&lt;/p&gt;</summary><content type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;I recently started to set up some resources on AWS for my side projects.
For starters an AWS KMS key so I can encrypt data on S3 and in the AWS SSM Parameter Store.
To use S3 and DynamoDB as backend and perform end-to-end state encryption for OpenTofu,
I also needed an IAM User. So the Idea was to write a CloudFormation template that
creates all these resources for me and then use it to deploy other Infrastructure as code via OpenTofu.
I'm not a huge fan of IAM Users and access keys, but in this case good enough to get started.&lt;/p&gt;
&lt;p&gt;What I wanted: The generated access and secret key are stored in AWS SSM Parameter store.
That way I don't have to deal with clear text credentials in CloudFormation.&lt;/p&gt;
&lt;p&gt;SSM Parameter Store can save Strings and SecureStrings. As the name implies, a SecureString
is encrypted via AWS KMS before put into SSM Parameter Store. But then I learned, neither Cfn nor CDK
support it. They can only write clear text Strings to the Parameter Store. What a bummer and pretty unexpected.&lt;/p&gt;
&lt;p&gt;So after some research, a Cfn CustomResource is what I need. It's basically a Lambda function
that receives a Create/Update/Delete request from Cfn, performs an action and sends the result back to the Stack.
It took me a bit to get something together but now it works like a charm.&lt;/p&gt;
&lt;p&gt;I'm still a bit disappointed that such a common feature isn't supported. Arguments are mostly
that Cfn and CDK are not supposed to deal with secrets. I can understand that, but putting some
data that were generated during a Cfn run into the parameter store can't be that unique.&lt;/p&gt;
&lt;p&gt;I published my Lambda Function to interact with AWS SSM Parameter Store SecureString under MIT:
&lt;a class="reference external" href="https://git.sr.ht/~wombelix/cfn-custom-resource-aws-ssm-securestring"&gt;https://git.sr.ht/~wombelix/cfn-custom-resource-aws-ssm-securestring&lt;/a&gt;&lt;/p&gt;
</content><category term="Cloud"/><category term="AWS"/><category term="SSM"/><category term="CloudFormation"/><category term="CDK"/><category term="Lambda"/></entry></feed>