简体   繁体   中英

Can't get configuration profile of AppConfig from AWS Lambda function

Lambda function - Node.js

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.

"Action": "appconfig:*"

Anyone solved this issue before me? Thank you.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM