我对 aws 帐户具有编程访问权限,当我尝试部署基本功能时,我得到:
用户:arn:aws:iam::xxxx:user/myname 无权执行:cloudformation:DescribeStacks on resource:arn:aws:cloudformation:eu-west-1:xxxxxx:stack/hello-world-dev/*
我检查了我的密钥,它们是正确的,我假设我的用户没有 cloudformation 访问权限。
我的问题是,是否可以在 yaml 文件中为我的用户设置权限?例如 cloudformation 完全访问、lambda 完全访问等。
您可以在下面找到我的函数和 yaml 文件:
handler.js
module.exports.helloWorld = (event, context, callback) => {
const response = {
statusCode: 200,
headers: {
'Access-Control-Allow-Origin': '*', // Required for CORS support to work
},
body: JSON.stringify({
message: 'Go Serverless v1.0! Your function executed successfully!',
input: event,
}),
};
callback(null, response);
};
无服务器.yaml
service: hello-world
provider:
name: aws
runtime: nodejs8.10
region: eu-west-1
# iamRoleStatements:
# - Effect: "Allow"
# Action:
# - cloudformation: CreateStack
# - cloudformation: DescribeStacks
# - cloudformation: CreateChangeSet
# - cloudformation: ListStacks
# - cloudformation: UpdateStack
# - cloudformation: DescribeChangeSet
# - cloudformation: ExecuteChangeSet
# - iam: GetRole
# - lambda: UpdateFunctionCode
# - lambda: UpdateFunctionConfig
# - lambda: GetFunctionConfiguration
# - lambda: AddPermission
# - s3: GetObject
# Resource: "*"
# The `functions` block defines what code to deploy
functions:
helloWorld:
handler: handler.helloWorld
# The `events` block defines how to trigger the handler.helloWorld code
events:
- http:
path: hello-world
method: get
cors: true