|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * observability/monitoring/enabling-monitoring-for-user-defined-projects.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="aws-encryption-key_{context}"] |
| 7 | += Create an AWS KMS encryption key |
| 8 | + |
| 9 | +[role="_abstract"] |
| 10 | +Using your AWS account and the `aws` CLI tool, you can create an AWS KMS encryption key to encypt your resources. |
| 11 | + |
| 12 | +.Procedure |
| 13 | + |
| 14 | +. Set the AWS region where you installed your VPC by running the following command: |
| 15 | ++ |
| 16 | +[NOTE] |
| 17 | +==== |
| 18 | +You should use the same region where you installed your VPC. |
| 19 | +==== |
| 20 | ++ |
| 21 | +[source,terminal] |
| 22 | +---- |
| 23 | +$ AWS_REGION=<aws_region> |
| 24 | +---- |
| 25 | + |
| 26 | +. Create a custom AWS customer-managed KMS key by running the following command: |
| 27 | ++ |
| 28 | +[source,terminal] |
| 29 | +---- |
| 30 | +$ KMS_ARN=$(aws kms create-key --region $AWS_REGION --description 'Custom ROSA Encryption Key' --tags TagKey=red-hat,TagValue=true --query KeyMetadata.Arn --output text) |
| 31 | +---- |
| 32 | ++ |
| 33 | +This command saves the Amazon Resource Name (ARN) output of this custom key for further steps. |
| 34 | ++ |
| 35 | +[NOTE] |
| 36 | +==== |
| 37 | +Customers must provide the `--tags TagKey=red-hat,TagValue=true` argument that is required for a customer KMS key. |
| 38 | +==== |
| 39 | + |
| 40 | +. Verify the KMS key has been created by running the following command: |
| 41 | ++ |
| 42 | +[source,terminal] |
| 43 | +---- |
| 44 | +$ echo $KMS_ARN |
| 45 | +---- |
| 46 | + |
| 47 | +. Set your AWS account ID to an environment variable by running the following command: |
| 48 | ++ |
| 49 | +[source,terminal] |
| 50 | +---- |
| 51 | +$ AWS_ACCOUNT=$(aws sts get-caller-identity --query Account --output text) |
| 52 | +---- |
| 53 | + |
| 54 | +. Create your AWS key policy by running the following command. |
| 55 | ++ |
| 56 | +[NOTE] |
| 57 | +==== |
| 58 | +If you use the default prefix, you need to modify the following code sample where you see `{PREFIX}-` to `ManagedOpenShift-`. |
| 59 | +==== |
| 60 | ++ |
| 61 | +[source,terminal] |
| 62 | +---- |
| 63 | +cat << EOF > rosa-key-policy.json |
| 64 | +{ |
| 65 | + "Version": "2012-10-17", |
| 66 | + "Id": "key-rosa-policy-1", |
| 67 | + "Statement": [ |
| 68 | + { |
| 69 | + "Sid": "Enable IAM User Permissions", |
| 70 | + "Effect": "Allow", |
| 71 | + "Principal": { |
| 72 | + "AWS": "arn:aws:iam::${AWS_ACCOUNT}:root" |
| 73 | + }, |
| 74 | + "Action": "kms:*", |
| 75 | + "Resource": "*" |
| 76 | + }, |
| 77 | + { |
| 78 | + "Sid": "Allow ROSA use of the key", |
| 79 | + "Effect": "Allow", |
| 80 | + "Principal": { |
| 81 | + "AWS": [ |
| 82 | + "arn:aws:iam::${AWS_ACCOUNT}:role/${PREFIX}-HCP-ROSA-Support-Role", |
| 83 | + "arn:aws:iam::${AWS_ACCOUNT}:role/${PREFIX}-HCP-ROSA-Installer-Role", |
| 84 | + "arn:aws:iam::${AWS_ACCOUNT}:role/${PREFIX}-HCP-ROSA-Worker-Role", |
| 85 | + "arn:aws:iam::${AWS_ACCOUNT}:role/${PREFIX}-openshift-cluster-csi-drivers-ebs-cloud-credentials", |
| 86 | + "arn:aws:iam::${AWS_ACCOUNT}:role/${PREFIX}-kube-system-kms-provider" |
| 87 | + ] |
| 88 | + }, |
| 89 | + "Action": [ |
| 90 | + "kms:Encrypt", |
| 91 | + "kms:Decrypt", |
| 92 | + "kms:ReEncrypt*", |
| 93 | + "kms:GenerateDataKey*", |
| 94 | + "kms:DescribeKey" |
| 95 | + ], |
| 96 | + "Resource": "*" |
| 97 | + }, |
| 98 | + { |
| 99 | + "Sid": "Allow attachment of persistent resources", |
| 100 | + "Effect": "Allow", |
| 101 | + "Principal": { |
| 102 | + "AWS": [ |
| 103 | + "arn:aws:iam::${AWS_ACCOUNT}:role/${PREFIX}-HCP-ROSA-Support-Role", |
| 104 | + "arn:aws:iam::${AWS_ACCOUNT}:role/${PREFIX}-HCP-ROSA-Installer-Role", |
| 105 | + "arn:aws:iam::${AWS_ACCOUNT}:role/${PREFIX}-HCP-ROSA-Worker-Role", |
| 106 | + "arn:aws:iam::${AWS_ACCOUNT}:role/${PREFIX}-openshift-cluster-csi-drivers-ebs-cloud-credentials" |
| 107 | + ] |
| 108 | + }, |
| 109 | + "Action": [ |
| 110 | + "kms:CreateGrant", |
| 111 | + "kms:ListGrants", |
| 112 | + "kms:RevokeGrant" |
| 113 | + ], |
| 114 | + "Resource": "*", |
| 115 | + "Condition": { |
| 116 | + "Bool": { |
| 117 | + "kms:GrantIsForAWSResource": "true" |
| 118 | + } |
| 119 | + } |
| 120 | + } |
| 121 | + ] |
| 122 | +} |
| 123 | +EOF |
| 124 | +---- |
| 125 | + |
| 126 | +. Confirm the details of the policy file created by running the following command: |
| 127 | ++ |
| 128 | +[source,terminal] |
| 129 | +---- |
| 130 | +$ cat rosa-key-policy.json |
| 131 | +---- |
| 132 | + |
| 133 | +. Apply the newly generated key policy to the custom KMS key by running the following command: |
| 134 | ++ |
| 135 | +[source,terminal] |
| 136 | +---- |
| 137 | +aws kms put-key-policy --key-id $KMS_ARN --policy file://rosa-key-policy.json --policy-name default |
| 138 | +---- |
| 139 | ++ |
| 140 | +You can now create your cluster using this AWS KMS encryption key. |
0 commit comments