-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws_ssm: When creating or consuming an SSM Parameter w/ a simple name, the arn attribute of Parameter/IParameter construct contains an extra slash after 'parameter' in the arn. #28778
Comments
Thank you for the detailed report and proposed solutions. I am making it a p1 as it's not easy to work it around but we welcome any PRs from the community as well. |
Hi @mttwise, thanks for the thorough and detail descriptions. It really helps my investigation a lot easier. I can confirm that I am able to reproduce the issues. However, I do not think this is a bug in the code but a usage issue. Here is my reasoning: In your first use case, you need to use a token for the prefix of the string parameter. However, based on the looking of your parameter name, For the second use case, I think it's the same issue where this does not satisfy the requirement of being a simple name, yet you gave That being said, what I can offer is to add a |
|
1 similar comment
|
@GavinZZ Thanks for the detailed info, I'm testing out setting simple_name to false and using in conjunction with force_dynamic_reference for reads w/ tokens. I'll update and let you know if the issue is resolved now. For a little more context, my original design included using a full token for the parameter_name, but later started using "/{token_after_slash}" which most likely is the reason why setting simple_name="False" will now work. I think this remains an issue if you are using a fully qualified token name for the entire SSM param name since the cdk synth will throw an error complaining about the lack of '/' prefix in this case when simple_name=False |
Describe the bug
Scenario 1: I am creating an ssm parameter in CDK. I have to use
simple_name=True
because i need to use a token for the prefix. I pass the parameter path to an IAM policy using the parameter methodparameter_arn
.After creating the
StringParameter
, theparameter_arn
property is used in an IAM role to grant access to read the parameter:The resulting policy in the synth'd template.json looks like this:
Note that within the join, the
parameter
string has a/
so it gets concatenated with theRef MyParameter
(which contains a/
already)The resultant ARN gets an extra slash so it looks like this:
arn:aws:ssm:us-east-1:1111111111111:parameter//prefix/for/parameter/path/for/my/parameter
Scenario 2: I want to dynamically consume an existing SSM Parameter at deploy time of my synth'd CFN template.
Example: Use the value of a CfnParameter in the path of an SSM String Parameter lookup:
In this scenario, two differing results are observed depending on how the IParameter is used.
the resulting CloudFormation Template gets a
resolve
string that contains a double/
if the FormatArn function is used or if the IParameter is passed to another construct such as an ECS Task for use in Secrets.When using
parameter.string_value
, the correct resolve string is observed:This effectively looks like this:
{{resolve:ssm://prefix/some-id/path/to/my/parameter}}
However, when the IParameter is passed to the task_definition.add_container function, a second slash is observed in the resultant secret property in CFN.
Note that the second slash is being inserted during synth.
The resultant CFN Template resolve looks like this:
There are two issues here, the first is that the account and region are being hardcoded despite the string being dynamic. The second is that there is an extra slash after
parameter
in the arn.In addition, the biggest issue is that there is a difference in behavior between the resolve string from
string_value
and how the ARN is generated.Expected Behavior
When using SSM Parameter/IParameter constructs with
simple_name=True
, the construct should not add an additional/
before the ARN/resolve strings.Current Behavior
Included in bug description.
Reproduction Steps
Included in bug description
Possible Solution
For backwards compatibility, there could be a new additional property used in conjunction with
simple_name=True
to allow setting the construct to not add the slash.Another solution could be removing the validation that there are no tokens in SSM parameters when not using the 'simple_name' parameter
Additional Information/Context
No response
CDK CLI Version
2.117.0
Framework Version
No response
Node.js Version
v18.17.1
OS
OSX Sonoma
Language
Python
Language Version
3.10.11
Other information
No response
The text was updated successfully, but these errors were encountered: