I have a CDK app with a CloudFormation Stack Parameter something like:
project_name_param = cdk.CfnParameter(
self,
"ProjectName",
default="MyCoolProject",
)
Since multiple instances of this stack can be deployed, I'd like to create an SSM Parameter with name based on this project name, to keep things organized.
In plain CloudFormation, this could be achieved achieved by e.g:
MyCoolResourceArnParam:
Type: 'AWS::SSM::Parameter'
Properties:
Description: ARN of this project's MyCoolResource
Name: !Sub '/Projects/${ProjectName}/MyCoolResource'
Type: String
Value: !GetAtt MyCoolResourceArn
...But I'm struggling to figure out how I'd use the project_id_param
object in CDK to achieve the same thing. For e.g. have tried and failed with various combinations similar to:
input_bucket_ssm_param = ssm.StringParameter(
self,
"MyCoolResourceSSMParam",
string_value=my_cool_resource.arn,
description="...",
parameter_name=cdk.Fn.sub(
f"/Projects/{project_name_param.value_as_string}/MyCoolResource"
),
)
Probably I'm missing something basic as still pretty new to using CFn parameters in CDK - can anybody enlighten me on how it's supposed to work?