AWS 电信网络构建器基于身份的策略示例 - AWS 电信网络生成器

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

AWS 电信网络构建器基于身份的策略示例

默认情况下,用户和角色无权创建或修改 AWS TNB资源。他们也无法使用 AWS Management Console、 AWS Command Line Interface (AWS CLI) 或来执行任务 AWS API。要授予用户对其所需资源执行操作的权限,IAM管理员可以创建IAM策略。然后,管理员可以将IAM策略添加到角色中,用户可以代入这些角色。

要了解如何使用这些示例策略文档创建IAM基于身份的JSON策略,请参阅IAM用户指南中的创建IAM策略(控制台)

有关由定义的操作和资源类型(包括每种资源类型的格式)的详细信息 AWS TNB,请参阅《服务授权参考》中的 AWS Telco Network Builder 的操作、资源和条件密钥。ARNs

策略最佳实践

基于身份的策略决定了某人是否可以在您的账户中创建、访问或删除 AWS TNB资源。这些操作可能会使 AWS 账户产生成本。创建或编辑基于身份的策略时,请遵循以下指南和建议:

  • 开始使用 AWS 托管策略并转向最低权限权限 — 要开始向用户和工作负载授予权限,请使用为许多常见用例授予权限的AWS 托管策略。它们在你的版本中可用 AWS 账户。我们建议您通过定义针对您的用例的 AWS 客户托管策略来进一步减少权限。有关更多信息,请参阅《IAM用户指南》中的AWS 托AWS 管策略或工作职能托管策略。

  • 应用最低权限权限-使用IAM策略设置权限时,仅授予执行任务所需的权限。为此,您可以定义在特定条件下可以对特定资源执行的操作,也称为最低权限许可。有关使用应用权限IAM的更多信息,请参阅《IAM用户指南》IAM中的策略和权限

  • 使用IAM策略中的条件进一步限制访问权限-您可以在策略中添加条件以限制对操作和资源的访问权限。例如,您可以编写一个策略条件来指定所有请求都必须使用发送SSL。如果服务操作是通过特定的方式使用的,则也可以使用条件来授予对服务操作的访问权限 AWS 服务,例如 AWS CloudFormation。有关更多信息,请参阅《IAM用户指南》中的IAMJSON策略元素:条件

  • 使用 A IAM ccess Analyzer 验证您的IAM策略以确保权限的安全性和功能性 — A IAM ccess Analyzer 会验证新的和现有的策略,以便策略符合IAM策略语言 (JSON) 和IAM最佳实践。IAMAccess Analyzer 提供了 100 多项策略检查和可行的建议,可帮助您制定安全和实用的策略。有关更多信息,请参阅IAM用户指南中的使用 A IAMccess Analyzer 验证策略

  • 需要多重身份验证 (MFA)-如果您的场景需要IAM用户或 root 用户 AWS 账户,请打开MFA以提高安全性。要要求MFA何时调用API操作,请在策略中添加MFA条件。有关更多信息,请参阅《IAM用户指南》MFA中的使用进行安全API访问

有关中最佳做法的更多信息IAM,请参阅《IAM用户指南》IAM中的安全最佳实践

使用控制 AWS TNB台

要访问 AWS Telco Network Builder 控制台,您必须拥有一组最低权限。这些权限必须允许您列出和查看有关您的 AWS TNB资源的详细信息 AWS 账户。如果创建比必需的最低权限更为严格的基于身份的策略,对于附加了该策略的实体(用户或角色),控制台将无法按预期正常运行。

您无需为仅拨打 AWS CLI 或的用户设置最低控制台权限 AWS API。相反,只允许访问与他们尝试执行的API操作相匹配的操作。

服务角色策略示例

作为管理员,您拥有并管理根据环境和服务模板定义 AWS TNB创建的资源。您必须将IAM服务角色附加到您的账户, AWS TNB才能为网络生命周期管理创建资源。

IAM服务角色 AWS TNB允许您代表您调用资源,以实例化和管理您的网络。如果您指定服务角色,则 AWS TNB使用该角色的凭据。

您可以使用服务创建服务角色及其权限策略。IAM有关创建服务角色的更多信息,请参阅《IAM用户指南》中的创建角色以向 AWS 服务委派权限

作为平台团队的成员,您可以以管理员身份创建 AWS TNB服务角色并将其提供给 AWS TNB。此角色 AWS TNB允许调用其他服务,例如 Amazon Elastic Kubernetes Serv AWS CloudFormation ice Amazon Kubernetes Service,为您的网络配置所需的基础设施,并按照您的定义配置网络功能。NSD

我们建议您对 AWS TNB服务IAM角色使用以下角色和信任策略。在缩小此策略的权限范围时,请记住,对于从您的策略中解除的资源, AWS TNB可能会因访问被拒绝错误而失败。

以下代码显示了 AWS TNB服务角色策略:

{ "Version": "2012-10-17", "Statement": [ { "Action": [ "sts:GetCallerIdentity" ], "Resource": "*", "Effect": "Allow", "Sid": "AssumeRole" }, { "Action": [ "tnb:*" ], "Resource": "*", "Effect": "Allow", "Sid": "TNBPolicy" }, { "Action": [ "iam:AddRoleToInstanceProfile", "iam:CreateInstanceProfile", "iam:DeleteInstanceProfile", "iam:GetInstanceProfile", "iam:RemoveRoleFromInstanceProfile", "iam:TagInstanceProfile", "iam:UntagInstanceProfile" ], "Resource": "*", "Effect": "Allow", "Sid": "IAMPolicy" }, { "Condition": { "StringEquals": { "iam:AWSServiceName": [ "eks.amazonaws.com", "eks-nodegroup.amazonaws.com" ] } }, "Action": [ "iam:CreateServiceLinkedRole" ], "Resource": "*", "Effect": "Allow", "Sid": "TNBAccessSLRPermissions" }, { "Action": [ "autoscaling:CreateAutoScalingGroup", "autoscaling:CreateOrUpdateTags", "autoscaling:DeleteAutoScalingGroup", "autoscaling:DeleteTags", "autoscaling:DescribeAutoScalingGroups", "autoscaling:DescribeAutoScalingInstances", "autoscaling:DescribeScalingActivities", "autoscaling:DescribeTags", "autoscaling:UpdateAutoScalingGroup", "ec2:AuthorizeSecurityGroupEgress", "ec2:AuthorizeSecurityGroupIngress", "ec2:CreateLaunchTemplate", "ec2:CreateLaunchTemplateVersion", "ec2:CreateSecurityGroup", "ec2:DeleteLaunchTemplateVersions", "ec2:DescribeLaunchTemplates", "ec2:DescribeLaunchTemplateVersions", "ec2:DeleteLaunchTemplate", "ec2:DeleteSecurityGroup", "ec2:DescribeSecurityGroups", "ec2:DescribeTags", "ec2:GetLaunchTemplateData", "ec2:RevokeSecurityGroupEgress", "ec2:RevokeSecurityGroupIngress", "ec2:RunInstances", "ec2:AssociateRouteTable", "ec2:AttachInternetGateway", "ec2:CreateInternetGateway", "ec2:CreateNetworkInterface", "ec2:CreateRoute", "ec2:CreateRouteTable", "ec2:CreateSubnet", "ec2:CreateTags", "ec2:CreateVpc", "ec2:DeleteInternetGateway", "ec2:DeleteNetworkInterface", "ec2:DeleteRoute", "ec2:DeleteRouteTable", "ec2:DeleteSubnet", "ec2:DeleteTags", "ec2:DeleteVpc", "ec2:DetachNetworkInterface", "ec2:DescribeInstances", "ec2:DescribeInternetGateways", "ec2:DescribeKeyPairs", "ec2:DescribeNetworkInterfaces", "ec2:DescribeRouteTables", "ec2:DescribeSecurityGroupRules", "ec2:DescribeSubnets", "ec2:DescribeVpcs", "ec2:DetachInternetGateway", "ec2:DisassociateRouteTable", "ec2:ModifySecurityGroupRules", "ec2:ModifySubnetAttribute", "ec2:ModifyVpcAttribute", "ec2:AllocateAddress", "ec2:AssignIpv6Addresses", "ec2:AssociateAddress", "ec2:AssociateNatGatewayAddress", "ec2:AssociateVpcCidrBlock", "ec2:CreateEgressOnlyInternetGateway", "ec2:CreateNatGateway", "ec2:DeleteEgressOnlyInternetGateway", "ec2:DeleteNatGateway", "ec2:DescribeAddresses", "ec2:DescribeEgressOnlyInternetGateways", "ec2:DescribeNatGateways", "ec2:DisassociateAddress", "ec2:DisassociateNatGatewayAddress", "ec2:DisassociateVpcCidrBlock", "ec2:ReleaseAddress", "ec2:UnassignIpv6Addresses", "ec2:DescribeImages", "eks:CreateCluster", "eks:ListClusters", "eks:RegisterCluster", "eks:TagResource", "eks:DescribeAddonVersions", "events:DescribeRule", "iam:GetRole", "iam:ListAttachedRolePolicies", "iam:PassRole" ], "Resource": "*", "Effect": "Allow", "Sid": "TNBAccessComputePerms" }, { "Action": [ "codebuild:BatchDeleteBuilds", "codebuild:BatchGetBuilds", "codebuild:CreateProject", "codebuild:DeleteProject", "codebuild:ListBuildsForProject", "codebuild:StartBuild", "codebuild:StopBuild", "events:DeleteRule", "events:PutRule", "events:PutTargets", "events:RemoveTargets", "s3:CreateBucket", "s3:GetBucketAcl", "s3:GetObject", "eks:DescribeNodegroup", "eks:DeleteNodegroup", "eks:AssociateIdentityProviderConfig", "eks:CreateNodegroup", "eks:DeleteCluster", "eks:DeregisterCluster", "eks:UpdateAddon", "eks:UpdateClusterVersion", "eks:UpdateNodegroupConfig", "eks:UpdateNodegroupVersion", "eks:DescribeUpdate", "eks:UntagResource", "eks:DescribeCluster", "eks:ListNodegroups", "eks:CreateAddon", "eks:DeleteAddon", "eks:DescribeAddon", "eks:DescribeAddonVersions", "s3:PutObject", "cloudformation:CreateStack", "cloudformation:DeleteStack", "cloudformation:DescribeStackResources", "cloudformation:DescribeStacks", "cloudformation:UpdateStack", "cloudformation:UpdateTerminationProtection" ], "Resource": [ "arn:aws:events:*:*:rule/tnb*", "arn:aws:codebuild:*:*:project/tnb*", "arn:aws:logs:*:*:log-group:/aws/tnb*", "arn:aws:s3:::tnb*", "arn:aws:eks:*:*:addon/tnb*/*/*", "arn:aws:eks:*:*:cluster/tnb*", "arn:aws:eks:*:*:nodegroup/tnb*/tnb*/*", "arn:aws:cloudformation:*:*:stack/tnb*" ], "Effect": "Allow", "Sid": "TNBAccessInfraResourcePerms" }, { "Sid": "CFNTemplatePerms", "Effect": "Allow", "Action": [ "cloudformation:GetTemplateSummary" ], "Resource": "*" }, { "Sid": "ImageAMISSMPerms", "Effect": "Allow", "Action": [ "ssm:GetParameters" ], "Resource": [ "arn:aws:ssm:*::parameter/aws/service/eks/optimized-ami/*", "arn:aws:ssm:*::parameter/aws/service/bottlerocket/*" ] }, { "Action": [ "tag:GetResources" ], "Resource": "*", "Effect": "Allow", "Sid": "TaggingPolicy" }, { "Action": [ "outposts:GetOutpost" ], "Resource": "*", "Effect": "Allow", "Sid": "OutpostPolicy" } ] }

以下代码显示了 AWS TNB服务信任策略:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "ec2.amazonaws.com" }, "Action": "sts:AssumeRole" }, { "Effect": "Allow", "Principal": { "Service": "events.amazonaws.com" }, "Action": "sts:AssumeRole" }, { "Effect": "Allow", "Principal": { "Service": "codebuild.amazonaws.com" }, "Action": "sts:AssumeRole" }, { "Effect": "Allow", "Principal": { "Service": "eks.amazonaws.com" }, "Action": "sts:AssumeRole" }, { "Effect": "Allow", "Principal": { "Service": "tnb.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }

当您在中创建 Amazon EKS 资源时NSD,您需要提供cluster_role属性来指定将使用哪个角色来创建您的 Amazon EKS 集群。

以下示例显示了为 Amazon EKS 集群策略创建 AWS TNB服务角色的 AWS CloudFormation 模板。

AWSTemplateFormatVersion: "2010-09-09" Resources: TNBEKSClusterRole: Type: "AWS::IAM::Role" Properties: RoleName: "TNBEKSClusterRole" AssumeRolePolicyDocument: Version: "2012-10-17" Statement: - Effect: Allow Principal: Service: - eks.amazonaws.com Action: - "sts:AssumeRole" Path: / ManagedPolicyArns: - !Sub "arn:${AWS::Partition}:iam::aws:policy/AmazonEKSClusterPolicy"

有关使用 AWS CloudFormation 模板的IAM角色的更多信息,请参阅《AWS CloudFormation 用户指南》中的以下部分:

在中创建 Amazon EKS 节点组资源时NSD,您需要提供node_role属性来指定将使用哪个角色来创建您的 Amazon EKS 节点组。

以下示例显示了为 Amazon EKS 节点组策略创建 AWS TNB服务角色的 AWS CloudFormation 模板。

AWSTemplateFormatVersion: "2010-09-09" Resources: TNBEKSNodeRole: Type: "AWS::IAM::Role" Properties: RoleName: "TNBEKSNodeRole" AssumeRolePolicyDocument: Version: "2012-10-17" Statement: - Effect: Allow Principal: Service: - ec2.amazonaws.com Action: - "sts:AssumeRole" Path: / ManagedPolicyArns: - !Sub "arn:${AWS::Partition}:iam::aws:policy/AmazonEKSWorkerNodePolicy" - !Sub "arn:${AWS::Partition}:iam::aws:policy/AmazonEKS_CNI_Policy" - !Sub "arn:${AWS::Partition}:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly" - !Sub "arn:${AWS::Partition}:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy" Policies: - PolicyName: EKSNodeRoleInlinePolicy PolicyDocument: Version: "2012-10-17" Statement: - Effect: Allow Action: - "logs:DescribeLogStreams" - "logs:PutLogEvents" - "logs:CreateLogGroup" - "logs:CreateLogStream" Resource: "arn:aws:logs:*:*:log-group:/aws/tnb/tnb*" - PolicyName: EKSNodeRoleIpv6CNIPolicy PolicyDocument: Version: "2012-10-17" Statement: - Effect: Allow Action: - "ec2:AssignIpv6Addresses" Resource: "arn:aws:ec2:*:*:network-interface/*"

有关使用 AWS CloudFormation 模板的IAM角色的更多信息,请参阅《AWS CloudFormation 用户指南》中的以下部分:

当您在中创建 Amazon EKS 资源NSD并希望将 Multus 作为部署模板的一部分进行管理时,必须提供multus_role属性以指定将使用哪个角色来管理 Multus。

以下示例显示了为 Multus 策略创建 AWS TNB服务角色的 AWS CloudFormation 模板。

AWSTemplateFormatVersion: "2010-09-09" Resources: TNBMultusRole: Type: "AWS::IAM::Role" Properties: RoleName: "TNBMultusRole" AssumeRolePolicyDocument: Version: "2012-10-17" Statement: - Effect: Allow Principal: Service: - events.amazonaws.com Action: - "sts:AssumeRole" - Effect: Allow Principal: Service: - codebuild.amazonaws.com Action: - "sts:AssumeRole" Path: / Policies: - PolicyName: MultusRoleInlinePolicy PolicyDocument: Version: "2012-10-17" Statement: - Effect: Allow Action: - "codebuild:StartBuild" - "logs:DescribeLogStreams" - "logs:PutLogEvents" - "logs:CreateLogGroup" - "logs:CreateLogStream" Resource: - "arn:aws:codebuild:*:*:project/tnb*" - "arn:aws:logs:*:*:log-group:/aws/tnb/*" - Effect: Allow Action: - "ec2:CreateNetworkInterface" - "ec2:ModifyNetworkInterfaceAttribute" - "ec2:AttachNetworkInterface" - "ec2:DeleteNetworkInterface" - "ec2:CreateTags" - "ec2:DetachNetworkInterface" Resource: "*"

有关使用 AWS CloudFormation 模板的IAM角色的更多信息,请参阅《AWS CloudFormation 用户指南》中的以下部分:

当你的NSD或网络函数包使用生命周期挂钩时,你需要一个服务角色来允许你创建执行生命周期挂钩的环境。

注意

您的生命周期挂钩策略应基于您的生命周期挂钩尝试执行的操作。

以下示例显示了为生命周期挂钩策略创建 AWS TNB服务角色的 AWS CloudFormation 模板。

AWSTemplateFormatVersion: "2010-09-09" Resources: TNBHookRole: Type: "AWS::IAM::Role" Properties: RoleName: "TNBHookRole" AssumeRolePolicyDocument: Version: "2012-10-17" Statement: - Effect: Allow Principal: Service: - codebuild.amazonaws.com Action: - "sts:AssumeRole" Path: / ManagedPolicyArns: - !Sub "arn:${AWS::Partition}:iam::aws:policy/AdministratorAccess"

有关使用 AWS CloudFormation 模板的IAM角色的更多信息,请参阅《AWS CloudFormation 用户指南》中的以下部分:

允许用户查看他们自己的权限

此示例说明如何创建允许IAM用户查看附加到其用户身份的内联和托管策略的策略。此策略包括在控制台上或使用或以编程方式完成此操作的 AWS CLI 权限。 AWS API

{ "Version": "2012-10-17", "Statement": [ { "Sid": "ViewOwnUserInfo", "Effect": "Allow", "Action": [ "iam:GetUserPolicy", "iam:ListGroupsForUser", "iam:ListAttachedUserPolicies", "iam:ListUserPolicies", "iam:GetUser" ], "Resource": ["arn:aws:iam::*:user/${aws:username}"] }, { "Sid": "NavigateInConsole", "Effect": "Allow", "Action": [ "iam:GetGroupPolicy", "iam:GetPolicyVersion", "iam:GetPolicy", "iam:ListAttachedGroupPolicies", "iam:ListGroupPolicies", "iam:ListPolicyVersions", "iam:ListPolicies", "iam:ListUsers" ], "Resource": "*" } ] }