Question:
Lambda function – Node.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
const AWS = require('aws-sdk') exports.handler = async (event) => { var appconfig = new AWS.AppConfig({ apiVersion: '2019-10-09' }) var params = { ApplicationId: '6xeris1', ConfigurationProfileId: '0ck2ijf' } const data = await appconfig.getConfigurationProfile(params).promise().catch(err => { console.log(err) }) if (data) { console.log(data) const response = { statusCode: 200, headers: { 'Access-Control-Allow-Headers': 'Content-Type', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'OPTIONS,POST,GET' }, body: JSON.stringify(data) } return response } else { const response = { statusCode: 500, headers: { 'Access-Control-Allow-Headers': 'Content-Type', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'OPTIONS,POST,GET' }, body: {} } return response } } |
When getConfigurationProfile
is called there is no response. No data, no error and the function get timeout.
I added below inline policy to Lambda execution IAM role, but it didn’t work.
1 2 |
"Action": "appconfig:*" |
Anyone solved this issue before me? Thank you.
Answer:
Based on the comments.
The issue was due to the fact that lambda function was configure to be in a VPC. However, functions in VPC don’t have internet access nor public IP. From docs:
Connecting a function to a public subnet doesn’t give it internet access or a public IP address.
The solution was to use VPC endpoint.