某些Atlas功能(包括Data Federation和静态加密)使用Amazon Web Services IAM 角色进行身份验证。当 Atlas 访问 Amazon Web Services 服务时,它会 担任 IAM 角色。
You can set up an assumed IAM role for your Atlas account to use with the Atlas Administration API or Atlas UI if you have the Project Owner role. Atlas supports unified access only for AWS.
您可以使用Atlas Kubernetes Operator为 AtlasProject 自定义资源中的 AWS IAM角色设立统一访问权限。
重要
If you operate Atlas Kubernetes Operator under an independent CRD model, you cannot configure AWS IAM authentication using atlasProject parameters. To configure AWS IAM authentication for your Atlas project directly, please see Set Up Authentication with AWS IAM.
先决条件
您需要以下公共 API 密钥、私有 API 密钥和组织 ID 信息, 配置 Atlas Kubernetes Operator 对 Atlas 的访问权限。
If you want Atlas Kubernetes Operator to create a new Atlas project, Grant Programmatic Access to an Organization. If your organization requires an IP access list for the Atlas Administration API, you must also configure the API access list.
重要
您必须为 API 密钥分配 Organization Project Creator 或更高级别的组织角色。
If you want to work with an existing Atlas project, Add Project Access from a Project. If your organization requires an IP access list for the Atlas Administration API, you must also configure the API access list.
重要
您必须为 API 密钥分配 Project Owner 项目角色。
您还可以使用 Service Accounts 作为 API 密钥的替代。
要了解更多信息,请参阅配置对 Atlas 的访问权限。
步骤
将spec.cloudProviderIntegrations 字段添加到AtlasProject 自定义资源。
在 spec.cloudProviderIntegrations.iamAssumedRoleArn 中指定一个空值占位符
AtlasProject自定义资源的参数。在 spec.cloudProviderIntegrations.providerName 中指定
AWSAtlasProject自定义资源的参数。
示例:
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: name: my-project spec: name: Test Project projectIpAccessList: - ipAddress: "192.0.2.15" comment: "IP address for Application" cloudProviderIntegrations: - providerName: "AWS" iamAssumedRoleArn: "" EOF
重要
在向AtlasProject自定义资源添加任何其他访问角色之前,请先完成整个过程,为空值占位符配置角色。
检索项目的 atlasAWSAccountArn 和 atlasAssumedRoleExternalId。
运行命令以检索后续步骤所需的
atlasAWSAccountArn。kubectl get atlasprojects my-project -o=jsonpath='{.status.cloudProviderIntegrations.atlasAWSAccountArn.type}' arn:aws:iam::198765432109:root 运行命令以检索后续步骤所需的
atlasAssumedRoleExternalId。kubectl get atlasprojects my-project -o=jsonpath='{.status.cloudProviderIntegrations.atlasAssumedRoleExternalId.type}' 1a234b56-c789-0d12-345e-67f89012345a
修改您的 AWS IAM角色信任策略。
您可以使用现有IAM角色,也可以创建新的IAM角色以实现统一访问。
使用以下自定义信任策略修改Amazon Web Services IAM角色的信任策略。将突出显示的行替换为您在上一步中检索到的值。
{ "Version":"2012-10-17", "Statement":[ { "Effect":"Allow", "Principal":{ "AWS":"<atlasAWSAccountArn>" }, "Action":"sts:AssumeRole", "Condition":{ "StringEquals":{ "sts:ExternalId":"<atlasAssumedRoleExternalId>" } } } ] }
使用以下自定义信任策略创建Amazon Web Services IAM角色。将突出显示的行替换为您在上一步中检索到的值。
{ "Version":"2012-10-17", "Statement":[ { "Effect":"Allow", "Principal":{ "AWS":"<atlasAWSAccountArn>" }, "Action":"sts:AssumeRole", "Condition":{ "StringEquals":{ "sts:ExternalId":"<atlasAssumedRoleExternalId>" } } } ] }
使用 Atlas Kubernetes Operator 授权 IAM 角色的访问权限。
替换 spec.cloudProviderIntegrations.iamAssumedRoleArn 中的空值占位符具有上一个步骤中 IAM 角色的 AWSAtlasProject ARN 的 自定义资源 的参数。
示例:
cat <<EOF | kubectl apply -f - apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: name: my-project spec: name: Test Project projectIpAccessList: - ipAddress: "192.0.2.15" comment: "IP address for Application" cloudProviderIntegrations: - providerName: "AWS" iamAssumedRoleArn: "arn:aws:iam::123456789012:role/aws-service-role/support.amazonaws.com/myRole" EOF
检查 cloudProviderIntegrations 的状态。
运行命令以检索状态:
kubectl get atlasprojects my-project -o=jsonpath='{.status.cloudProviderIntegrations}' 检查
READY状态。如果状态为
CREATED,则 Atlas 创建了该角色,但您尚未在Amazon Web Services中授权。如果状态为
EMPTY_ARN,则 Atlas 创建了角色,但您尚未指定spec.cloudProviderIntegrations.iamAssumedRoleArn。如果状态为
READY,则 Atlas 已创建角色,并且您已在Amazon Web Services中对其进行授权。