限制子网或CodeStar可以使用的托管区域的政策

问题描述 投票:0回答:1

是否存在可以创建/附加到CodeStarWorker-*-CloudFormation的IAM策略,以限制CodeStar工作人员可以使用的SubnetHostedZoneId

这是一个示例template.yml:

Resources:
  # other resources
  DevAlb:
    Properties:
      LoadBalancerAttributes: []
      Name: !Sub '${ProjectId}-dev-alb'
      Scheme: internal
      SecurityGroups:
        - !Ref AlbSecurityGroup
      Subnets:
        - !ImportValue PrivateSubnet1
        - !ImportValue PrivateSubnet2
      Tags:
        - Key: Name
          Value: !Sub '${ProjectId}-dev'
    Type: 'AWS::ElasticLoadBalancingV2::LoadBalancer'
  DevAlbDns:
    Properties:
      AliasTarget:
        DNSName: !GetAtt 
          - AlbDev
          - DNSName
        HostedZoneId: !GetAtt 
          - AlbDev
          - CanonicalHostedZoneID
      HostedZoneId: !ImportValue InternalDomainDotCom
      Name: !Sub '${ProjectId}.internal-domain.com'
      Type: A
    Type: 'AWS::Route53::RecordSet'

我不希望具有CodeStar访问权限的用户导入/使用任何允许公共互联网访问的内容(无论如何,未经管理员批准)。如何防止某人将PublicSubnet1PublicSubnet2设置/导入为Subnet之一?还是阻止他们将PublicDomainDotCom设置/导入为HostedZoneId

amazon-cloudformation amazon-route53 aws-codestar
1个回答
0
投票

通过将以下策略附加到CodeStarWorker-app-CloudFormation,我能够做到这一点!

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "route53:GetChange",
                "route53:GetHostedZone",
                "route53:ListHostedZones",
                "route53:ListHostedZonesByName",
                "route53:ListResourceRecordSets",
                "route53:GetHostedZoneCount",
                "route53domains:*"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "route53:ChangeResourceRecordSets",
                "route53:ListResourceRecordSets",
                "apigateway:GET"
            ],
            "Resource": [
                "arn:aws:route53:::hostedzone/REPLACE_WITH_HOSTED_ZONE_ID",
                "arn:aws:apigateway:*::/domainnames"
            ]
        }
    ]
}

这将仅允许CodeStar的CloudFormation角色在管理员允许的托管区域ID中创建Route 53记录集。

我确信还有其他方法可以保护您的基础结构和数据免受CodeStar角色的不良影响。有任何想法(例如,限制EC2 VPC /子网),请随时分享。

© www.soinside.com 2019 - 2024. All rights reserved.