Lambda 函数 - 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
}
}
当getConfigurationProfile
叫没有反应。没有数据,没有错误,函数超时。我向 Lambda 执行 IAM 角色添加了以下内联策略,但它不起作用。
"Action": "appconfig:*"
有人在我之前解决过这个问题吗?谢谢你。
最佳答案
根据评论。
问题是由于 lambda 函数被配置为 在 VPC 中 .但是,VPC 中的函数没有 Internet 访问权限,也没有公共(public) IP。来自 docs :
Connecting a function to a public subnet doesn't give it internet access or a public IP address.
解决方案 是使用 VPC endpoint .
关于amazon-web-services - 无法从 AWS Lambda 函数获取 AppConfig 的配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63543521/