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

APIGW - Method.methodArn not replacing path parameters with asterisks #8036

Closed
willdady opened this issue May 16, 2020 · 2 comments · Fixed by #8206
Closed

APIGW - Method.methodArn not replacing path parameters with asterisks #8036

willdady opened this issue May 16, 2020 · 2 comments · Fixed by #8206
Assignees
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway bug This issue is a bug. p2

Comments

@willdady
Copy link

API Gateway Method.methodArn incorrectly returns the ARN with named path parameters where they should have been replaced with asterisk.

For example, currently returning this:

arn:aws:execute-api:ap-southeast-2:000000000000:trjpwtzjyb/prod/PUT/foo/{myvariable}/bar

Should be this:

arn:aws:execute-api:ap-southeast-2:000000000000:trjpwtzjyb/prod/PUT/foo/*/bar

Reproduction Steps

// SNIP
const method = resource.addMethod(props.method, integration, {
  authorizationType: apigateway.AuthorizationType.IAM,
});

authenticatedRole.addToPolicy(
  new iam.PolicyStatement({
    actions: ['execute-api:Invoke'],
    effect: iam.Effect.ALLOW,
    resources: [method.methodArn], // <- WRONG
  })
);

Environment

  • CLI Version : 1.33.1
  • Framework Version: 1.33.1
  • **OS : ** Linux mint
  • **Language : ** Typescript

This is 🐛 Bug Report

@willdady willdady added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 16, 2020
@SomayaB SomayaB added the @aws-cdk/aws-apigateway Related to Amazon API Gateway label May 18, 2020
@nija-at
Copy link
Contributor

nija-at commented May 26, 2020

@willdady - can you also include code on how you constructed this Method class and all of its constructor properties?

EDIT: Sorry, not the Method class but the Resource class for ${myvariable}.

@nija-at nija-at added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels May 26, 2020
nija-at pushed a commit that referenced this issue May 26, 2020
Path parameters in API Gateway allows for paths to contain the resource
id, such as `/pets/{petId}/comments/{commentId}`. When generating the
ARN for a Method to this Resource, the path parameters should be placed
with asterisks, such as `/pets/*/comments/*`.

fixes #8036
nija-at pushed a commit that referenced this issue May 26, 2020
Path parameters in API Gateway allows for paths to contain the resource
id, such as `/pets/{petId}/comments/{commentId}`. When generating the
ARN for a Method to this Resource, the path parameters should be placed
with asterisks, such as `/pets/*/comments/*`.

fixes #8036
@nija-at
Copy link
Contributor

nija-at commented May 26, 2020

Update - I was able to reproduce this error and the fix is here - #8206

@nija-at nija-at added p2 and removed response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels May 26, 2020
@mergify mergify bot closed this as completed in #8206 Jun 8, 2020
mergify bot pushed a commit that referenced this issue Jun 8, 2020
…ks (#8206)

Path parameters in API Gateway allows for paths to contain the resource
id, such as `/pets/{petId}/comments/{commentId}`. When generating the
ARN for a Method to this Resource, the path parameters should be placed
with asterisks, such as `/pets/*/comments/*`.

fixes #8036


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway bug This issue is a bug. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants