简体   繁体   English

AWS IAM 策略基于父 Cloudformation 限制对资源的访问

[英]AWS IAM Policy restrict access to resources based on parent Cloudformation

Under our AWS account, we have multiple products which are each their own Cloudformation Stacks.在我们的 AWS 账户下,我们有多个产品,每个产品都是自己的 Cloudformation Stacks。 The entire products stack is Dynamo/Serverless/Cognito.整个产品堆栈是 Dynamo/Serverless/Cognito。

Recently one of our clients has brought in outside contractors to work on specific products.最近,我们的一位客户引入了外部承包商来处理特定产品。

Is there a way we can limit their access within our account to all resources deployed under a cloudformation?有没有办法限制他们在我们的帐户中访问部署在 cloudformation 下的所有资源?


I've tried the following by tagging resources under the cloudformation with enviroment (prod/master) & product tags:我通过使用环境(prod/master)和产品标签标记 cloudformation 下的资源来尝试以下操作:

{
  "PolicyDocument": {
    "Version": "2012-10-17",
    "Statement": [
      {
        "Effect": "Allow",
        "Action": "*",
        "Resource": "*",
        "Condition": {
          "ForAllValues:StringEquals": {
            "aws:ResourceTag/Product": "productName",
            "aws:ResourceTag/Environment": "productEnviroment"
          }
        }
      }
    ]
  }

This does not work and seems to give access to everything.这不起作用,似乎可以访问所有内容。 Reversing this and denying all but the tagged, then directly applying specific actions doesnt seem to work either.扭转这一点并拒绝除标记之外的所有内容,然后直接应用特定操作似乎也不起作用。

You can create Organization Units and add accounts to them which only have access to the resources within those OU's.您可以创建组织单位并向其添加帐户,这些帐户只能访问这些 OU 中的资源。 It's hierarchical, so your root account will have access to everything, so on and so forth.它是分层的,因此您的 root 帐户将可以访问所有内容,依此类推。

Organization -> OU1 -> OU2 -> OU3组织 -> OU1 -> OU2 -> OU3

There, unfortunately, is no CloudFormation for Organizations, but the CLI is pretty straightforward .不幸的是,没有 CloudFormation for Organizations,但CLI 非常简单

If you wanted to automate this, I would do something along the lines of:如果你想自动化这个,我会做一些事情:

  1. Create Org Unit/s under root/parent OU在根/父 OU 下创建组织单位
  2. Create Account (created in root)创建帐户(在 root 中创建)
  3. Move account from root to OU将帐户从 root 移动到 OU
  4. Generate an access key for account / create IAM and generate access key (unfortunately a 'one-off' manual task)为账户生成访问密钥/创建 IAM 并生成访问密钥(不幸的是“一次性”手动任务)
  5. Use the AWS credentials to deploy the CloudFormation stacks you wish to keep within that org unit使用 AWS 凭证部署您希望保留在该组织单位内的 CloudFormation 堆栈

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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