-
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
(secretsmanager): secret_full_arn not returning text after dash #33489
Comments
When you create the e.g. secret = secretsmanager.Secret(
scope=stack,
id="RdsDatabaseSecret",
description="Secret used for data catalyst modules",
secret_name=config.secret_name,
removal_policy=config.removal_policy,
generate_secret_string=secretsmanager.SecretStringGenerator(
secret_string_template='{"username":"rds_cdk_user"}',
generate_string_key="password",
exclude_punctuation=True,
exclude_characters='!@#$%^&*()[]{};:,.<>?/~`\\|'
)
)
// CfnOutput the secret.secret_full_arn to verify If it's correct then you can track when you receive this from a class, are you still able to get the full arn in the class? |
@pahud Both secret_arn and secret_full_arn give the same result and have the real Secret ARN. I also tried this outputs outside the class:
Both CfnOutput above return the real Secret ARN but the DMS IAM Role still got the wrong Secret ARN. Then, I tested this output inside the class:
This output inside the class gave me the wrong Secret ARN |
Interesting.
OK so this looks like cross-stack reference. Questions
Off the top of my head, if you are doing cross-stack reference. CDK essentially won't export the "concret" secret object and is very likely just export the name of the secret. When you import that in your consumer stack you are very likely only get the name of the secret so you won't have the fullarn which contains the last 6 chars. Let me know if it is the case. |
@pahud I am not sure if I completely understood your last question. Yes, I are creating two stacks, one for Secret and another for the DMS Endpoint The DMS Endpoint stack will use the Secret stack as input Secret stack is created like this:
And I will use this secretsmanager.Secret object inside the IAM class like this:
|
Let's consider this sample in python class ProducerStack(Stack):
def __init__(self, scope: Construct, id: str, **kwargs):
super().__init__(scope, id, **kwargs)
self.secret = secretsmanager.Secret(self, 'Secret',
secret_name='my-secret',
secret_string_value=SecretValue.unsafe_plain_text('supersecret')
)
CfnOutput(self, 'SecretOutput',
value=self.secret.secret_full_arn
)
class ConsumerStack(Stack):
def __init__(self, scope: Construct, id: str, secret: secretsmanager.Secret, **kwargs):
super().__init__(scope, id, **kwargs)
CfnOutput(self, 'SecretOutput',
value=secret.secret_full_arn
) and app = cdk.App()
producer = ProducerStack(app, "ProducerStack")
consumer = ConsumerStack(app, "ConsumerStack", secret=producer.secret) on
arn:aws:secretsmanager:us-east-1:ACCOUNT_ID:secret:my-secret-8ASRal And you should see this as well
This indicates the fullArn is exported as a string from the producer stack that could be imported by the consumer stack. Can you check if this works for you? |
Describe the bug
I am using Python and AWS CDK to deploy:
The secret is used in the RDS Instance.
My DMS Source Endpoint is the RDS Instance, the DMS IAM Role needs access to the secret and I am using this statement:
This statement fails because the secret_full_arn is not returning text after dash. For example:
The secret ARN is "arn:aws:secretsmanager:us-east-1:131578276461:secret:secret-for-data-platform-catalyst-Vg66GP". After the end of all CDK deployment, the IAM Role has secretsmanager permissions for "arn:aws:secretsmanager:us-east-1:131578276461:secret:secret-for-data-platform-catalyst". Note that "-Vg66GP" is missing.
I think this issue might be related to #11727
Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
I need the IAM role to have permissions for the real secret_arn
Current Behavior
When I use the statement below, secret_full_arn is not returning text after dash
Reproduction Steps
My secret is created here:
I use this secret as a class attribute:
My class has this method to create iam statements:
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.141.0
Framework Version
No response
Node.js Version
v22.1.0
OS
macOS 15.0 24A335
Language
Python
Language Version
3.13.0
Other information
No response
The text was updated successfully, but these errors were encountered: