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

AWS::ApiGatewayV2::Api - GetAtt-Arn #294

Open
iconara opened this issue Dec 7, 2019 · 4 comments
Open

AWS::ApiGatewayV2::Api - GetAtt-Arn #294

iconara opened this issue Dec 7, 2019 · 4 comments
Labels
enhancement New feature or request networking & content deliv VPC, CloudFront, Route 53, API Gateway, Direct Connect, AWS App Mesh, etc.

Comments

@iconara
Copy link

iconara commented Dec 7, 2019

Scope of request

AWS::ApiGatewayV2::Api does not support GetAtt.

Expected behavior

It should be possible to use GetAtt with a AWS::ApiGatewayV2::Api to get the ARN of the resource, e.g. !GetAtt MyApi.Arn.

Suggest specific test cases

Resources:
  Api:
    Type: AWS::ApiGatewayV2::Api
    Properties:
      Name: Lambda Proxy
      Description: Lambda proxy using quick create
      ProtocolType: HTTP
      Target: !Ref Function # this resource has been omitted for brevity

  ApiPermission:
    Type: AWS::Lambda::Permission
    Properties:
      Action: lambda:InvokeFunction
      FunctionName: !GetAtt Function.Arn # this resource has been omitted for brevity
      Principal: apigateway.amazonaws.com
      SourceArn: !GetAtt Api.Arn # this does not work

Category (required)

Networking & Content (API GW)

Workaround

You can work around the issue with !Ref:

  ApiPermission:
    Type: AWS::Lambda::Permission
    Properties:
      Action: lambda:InvokeFunction
      FunctionName: !GetAtt Function.Arn # this resource has been omitted for brevity
      Principal: apigateway.amazonaws.com
      SourceArn: !Sub 'arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${Api}/' # Api resource ommitted for brevity
@luiseduardocolon luiseduardocolon added enhancement New feature or request networking & content deliv VPC, CloudFront, Route 53, API Gateway, Direct Connect, AWS App Mesh, etc. labels Dec 9, 2019
@PatMyron
Copy link
Contributor

@iconara can use Psuedo Parameters as described here to generalize your workaround a bit more:
#68 (comment)
https://stackoverflow.com/a/59362496/4122849

      SourceArn: !Sub arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${Api}

@iconara
Copy link
Author

iconara commented Dec 19, 2019

@PatMyron yes, I updated the issue with your suggestion if anyone else comes across this and wants the use the workaround it's better that they use that one.

@simonbuchan
Copy link

At the moment only the resource ARN is documented: https://docs.aws.amazon.com/IAM/latest/UserGuide/list_amazonapigateway.html#amazonapigateway-resources-for-iam-policies
So the general form is:

      SourceArn: !Sub arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${Api}/${Stage}/${Method}/${Path}

But you can of course use [...]/${Api}/* to match everything on the API.

I suspect this is why the Arn attribute wasn't added, as technically there isn't an API ARN: only a common prefix. That said, it would be nice to be able to SourceArn: !Sub ${Api.Arn/*, SourceArn: !Sub ${Stage}/get/* etc...

@simonbuchan
Copy link

To elaborate this issue, there are also the "quick create" Stage, Integration and Route implicit resources created when you specify Target on the Api. You need at least the Stage ref in order to create an ApiMapping when you are providing a domain name. Presumably this would allow simplifying a lot of templates.

@WaelA WaelA changed the title AWS::ApiGatewayV2::Api-GetAtt-Arn AWS::ApiGatewayV2::Api - GetAtt-Arn Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request networking & content deliv VPC, CloudFront, Route 53, API Gateway, Direct Connect, AWS App Mesh, etc.
Projects
None yet
Development

No branches or pull requests

4 participants