'AWS Apigateway + Simple System Mangement + Integration
I'm trying to resolve an ssm parameter throught AWS Apigateway, but i can't find any example. The cloud formation part where I define the method integration is the follow:
Integration:
Type: AWS
Uri: !Sub "arn:aws:apigateway:us-west-2:ssm:action/GetParameter"
IntegrationHttpMethod: POST
PassthroughBehavior: NEVER
RequestTemplates:
application/json: '
{
"Name": "/dev/configs/xoxo"
}
'
When I test it in the AWS console this are the logs
Mon Aug 10 18:14:10 UTC 2020 : Method request body before transformations:
Mon Aug 10 18:14:10 UTC 2020 : Endpoint request URI: https://ssm.us-west-2.amazonaws.com/?Action=GetParameter
Mon Aug 10 18:14:10 UTC 2020 : Endpoint request headers: {Authorization=**********************************************************************************************************************************************************************************************************************************************************************dbf24f, X-Amz-Date=20200810T181410Z, x-amzn-apigateway-api-id=mrvijesndc, Accept=application/json, User-Agent=AmazonAPIGateway_mrvijesndc, X-Amz-Security-Token=...[TRUNCATED]
Mon Aug 10 18:14:10 UTC 2020 : Endpoint request body after transformations: { "Name": "/dev/configs/xoxo"}
Mon Aug 10 18:14:10 UTC 2020 : Sending request to https://ssm.us-west-2.amazonaws.com/?Action=GetParameter
Mon Aug 10 18:14:10 UTC 2020 : Received response. Status: 400, Integration latency: 43 ms
Mon Aug 10 18:14:10 UTC 2020 : Endpoint response headers: {Server=Server, Date=Mon, 10 Aug 2020 18:14:10 GMT, Content-Type=application/json, Content-Length=220, Connection=keep-alive, x-amzn-RequestId=c2e56a30-d846-4cd6-b4af-1df95267a3fd}
Mon Aug 10 18:14:10 UTC 2020 : Endpoint response body before transformations: {"Error":{"Code":"ValidationError","Message":"1 validation error detected: Value null at 'name' failed to satisfy constraint: Member must not be null.","Type":"Sender"},"RequestId":"c2e56a30-d846-4cd6-b4af-1df95267a3fd"}
I suppose it is not making the call correctly, could anyone help me ?
Solution 1:[1]
Well, after a long research, google hide this post for me along 8 hours, finally, I found it:
https://forums.aws.amazon.com/thread.jspa?threadID=288118
I hope be helpfully for someone like me in the future
Solution 2:[2]
Seems like the SSM API endpoint, when called in this manner, expects to find its parameters in the query string, not in the request body. So the following ought to work: (not tested as such, because I use Terraform instead of CloudFormation)
Integration:
Type: AWS
Uri: !Sub "arn:aws:apigateway:us-west-2:ssm:action/GetParameter"
IntegrationHttpMethod: POST
PassthroughBehavior: WHEN_NO_TEMPLATES
RequestParameters:
integration.request.querystring.Name: "'/dev/configs/xoxo'"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Manuel |
Solution 2 |