【问题标题】:How to set Cloudformation full access from the serverless cli如何从无服务器 cli 设置 Cloudformation 完全访问权限
【发布时间】:2019-02-21 06:18:47
【问题描述】:

我对 aws 帐户具有编程访问权限,当我尝试部署基本功能时,我得到:

用户:arn:aws:iam::xxxx:user/myname 无权执行:cloudformation:DescribeStacks on resource:arn:aws:cloudformation:eu-west-1:xxxxxx:stack/hello-世界开发/*

我检查了我的密钥并且它们是正确的,我假设我的用户没有 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);
};

serverless.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

【问题讨论】:

    标签: node.js aws-lambda amazon-cloudformation serverless aws-serverless


    【解决方案1】:

    所以这里的问题是您的默认 ~/.aws/credentials 密钥没有分配给它们的正确权限。

    您无法在 yaml 文件中为您的用户分配权限,您需要进入控制台并分配,您可以在资源部分创建用户,但这会违反直觉 - 我不太确定您的知识水平如何,如果您需要更多帮助,请发表评论,我会充实我的答案。

    您的部署角色/权限基本上应该具有 Lambda、IAM、Cloudformation 和 APIG 的完全访问权限。

    【讨论】:

      猜你喜欢
      • 2012-03-15
      • 1970-01-01
      • 1970-01-01
      • 2022-09-28
      • 2012-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-19
      相关资源
      最近更新 更多