question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

route53: HostedZone should have a `hostedZoneArn` property

See original GitHub issue

❓ General Issue

The Question

I’m trying to create a IAM group with a policy attached to change DNS records for a Route53 hosted zone.

This is my code:

const group = new iam.Group(this, 'group', {
      groupName: 'ci-ui-iam-group'
    })

const zone = route53.HostedZone.fromLookup(this, 'zone', {
      domainName: 'mydomain.com'
    })

group.addManagedPolicy(
      new iam.ManagedPolicy(this, 'AllowChangeRecordSets', {
        managedPolicyName: 'allow-change-record-sets',
        statements: [
          new iam.PolicyStatement({
            effect: iam.Effect.ALLOW,
            resources: [`arn:aws:route53:::${zone.hostedZoneId}`],
            actions: ['route53:ChangeResourceRecordSets']
          })
        ]
      })
    )

It creates the group as well as the policy, whose JSON looks like this:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "route53:ChangeResourceRecordSets",
      "Resource": "arn:aws:route53:::/hostedzone/<SomeHostedZoneId>",
      "Effect": "Allow"
    }
  ]
}

When opening the new Policy in AWS Console, I get this warning:

image

When changing the Resource entry like this (removing the / before hostedzone):

"Resource": "arn:aws:route53:::hostedzone/<SomeHostedZoneId>",

the policy is fixed.

So my question is: can I get hostedzone/<SomeHostedZoneId> using AWS CDK instead of /hostedzone/<SomeHostedZoneId> so I don’t have to remove the leading / myself?

Or even better: is there a function in the CDK which allows me to get the full ARN for this zone?

Environment

  • CDK CLI Version: 1.15.0
  • Module Version: 1.15.0
  • OS: Darwin mbp.local 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64 x86_64
  • Language: TypeScript

Other information

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
AlexZeitlercommented, Nov 27, 2019

Having consistent behavior between creating the HostedZone and importing it using route53.HostedZone.fromLookup would be great.

1reaction
abelmokademcommented, Nov 11, 2019

I think the entire /hostedzone/ part should be removed. This attribute should just return the ID of the hosted zone.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS::Route53::HostedZone - AWS CloudFormation
When creating private hosted zones, the Amazon VPC must belong to the same partition where the hosted zone is created. A partition is...
Read more >
AWS::Route53::HostedZone - Amazon CloudFormation
Creates a new public or private hosted zone. You create records in a public hosted zone to define how you want to route...
Read more >
How do I determine the ARN of my Amazon route53-hosted ...
Resource is either hostedzone or change , and ID is the ID of the hosted zone or the change. The following are examples...
Read more >
aws.route53.Record - Pulumi
Changes to this property will trigger replacement. string. Hosted zone ID for a CloudFront distribution, S3 bucket, ELB, or Route 53 hosted zone....
Read more >
Route53 - Go Packages
Package route53 provides the client and types for making API requests to Amazon Route 53. ... The hosted // zone and parent must...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found