Skip to content
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

CrossAccountZoneDelegationRecord: IAM policy propogation delay causes intermittent failures #29391

Closed
lognoel opened this issue Mar 7, 2024 · 5 comments
Assignees
Labels
@aws-cdk/aws-iam Related to AWS Identity and Access Management bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@lognoel
Copy link

lognoel commented Mar 7, 2024

Describe the bug

The CrossAccountZoneDelegationRecord intermittently fails to create a record with the following error:

Received response status [FAILED] from custom resource. Message returned: AccessDenied: User: [ROLE CREATED BY CrossAccountZoneDelegationRecord] is not authorized to perform: sts:AssumeRole on resource: [DNS DELEGATION ROLE IN OTHER ACCOUNT].
  • despite a valid trust policy on the delegation role in the target account. Retrying the stack deployment once or twice always fixes the issue. I have noticed that it is more likely to occur in regions with higher latency to the IAM global control plane in us-east-1. In ca-west-1, I estimate this failure occurs when deploying a new CrossAccountZoneDelegationRecord approximately 30% of the time.

Expected Behavior

The CrossAccountZoneDelegationRecord successfully creates a Cross Account Zone Delegation record when given a delegation role with accurate trust policies.

Current Behavior

The CrossAccountZoneDelegationRecord intermittently fails, likely due to IAM policy propagation delay.

Reproduction Steps

Deploy a new CrossAccountZoneDelegationRecord several times in a non-us AWS region.

Possible Solution

In a similar issue using custom resources (#18237), retries was one of the suggested fixes, which seems appropriate here as well.

Additional Information/Context

No response

CDK CLI Version

2.122.0

Framework Version

No response

Node.js Version

18

OS

MacOs

Language

TypeScript

Language Version

No response

Other information

No response

@lognoel lognoel added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 7, 2024
@github-actions github-actions bot added the @aws-cdk/aws-iam Related to AWS Identity and Access Management label Mar 7, 2024
@pahud
Copy link
Contributor

pahud commented Mar 7, 2024

Thank you for the report. This could be related to #18237 (comment) and I am making it a p1 bug.

Can you share a small code snippets with very minimal props that we can just copy/paste in our IDE and reproduce this error in ca-west-1 and us-east-1?

@pahud pahud added p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Mar 7, 2024
@lognoel
Copy link
Author

lognoel commented Mar 12, 2024

I'm not sure what code samples you want, the resource creation is very straightforward as specified by https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_route53.CrossAccountZoneDelegationRecord.html

@samson-keung
Copy link
Contributor

On the CrossAccountZoneDelegationRecord construct, there is an assumeRoleRegion option to set which region the STS AssumeRole call should go to. Here is the link to the option details in the CDK doc.

Were you able to see if setting this option to us-east-1 helps with the problem?

@pahud
Copy link
Contributor

pahud commented Sep 10, 2024

Hi @lognoel

I was able to deploy from ca-west-1 using the sample below:

export class DummyStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    const subZone = new route53.PublicHostedZone(this, 'SubZone', {
      zoneName: 'sub.example.com',
    });
    
    // import the delegation role by constructing the roleArn
    const delegationRoleArn = Stack.of(this).formatArn({
      region: '', // IAM is global in each partition
      service: 'iam',
      account: 'XXXXXXXXXXX',
      resource: 'role',
      resourceName: 'AdminRole4Switch',
    });
    const delegationRole = iam.Role.fromRoleArn(this, 'DelegationRole', delegationRoleArn);
    
    // create the record
    new route53.CrossAccountZoneDelegationRecord(this, 'delegate', {
      delegatedZone: subZone,
      parentHostedZoneName: 'example.com', // or you can use parentHostedZoneId
      delegationRole,
      assumeRoleRegion: 'us-east-1',
    });
  }
}

Let me know if it works for you.

@pahud pahud added p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed p1 labels Sep 10, 2024
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-iam Related to AWS Identity and Access Management bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

4 participants