Is it possible to create with Cloud Formation a child resource for an API Gateway resource created with AWS SAM?

1

I have an API Gateway defined with AWS SAM, it's resources and methods are defined implicitly by AWS::Serverless::Function (Events property).

The current API has the following path: /api/resource-A/{detail}/

I want to create a new method of lambda Non proxy integration type for the /detail/ path (which is a nested resource), but it requires to be defined with Cloud Formation using AWS::ApiGateway::Method as I need to use some apache-velocity-templates for data mapping.

Is it possible to define it as a method of the /{detail}/ resource created by SAM? Since there is a property called ResourceId that is not possible to retrieve from the generated resources of SAM for API events

Additional information: StackOverflow questionhttps://stackoverflow.com/questions/74647318/how-to-set-the-resourceid-in-awsapigatewaymethod-if-was-implicitly-created-b

1 Answer
0

SAM is just a transform so you can look at your template in the deployed Stack in the CF console, and switch on "View processed template". Any resources you're creating should be visible in there and their logical IDs can be referenced in your template code.

EXPERT
answered a year ago
  • Well, what I can see is that the only resources created by SAM when defining the API resources and methods in the event source of the Lambda function, are the REST API, the deployment, and the stage, the lambda function itself and some permissions, but there are no AWS::ApiGateway::Resource or AWS::ApiGateway::Method.

    Then I don't know if to access them all must be redefined using cloud formation

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions