File tree Expand file tree Collapse file tree
Open diff view settings
Expand file tree Collapse file tree
Open diff view settings
Original file line number Diff line number Diff line change 1+ resource "aws_kms_key" "my-kms-key" {
2+ description = " My KMS Keys for Data Encryption"
3+ enable_key_rotation = true
4+
5+ tags {
6+ Name = " my-kms-keys"
7+ }
8+
9+ policy = << EOF
10+ {
11+ "Version": "2012-10-17",
12+ "Id": "key-consolepolicy-3",
13+ "Statement": [
14+ {
15+ "Sid": "Enable IAM User Permissions",
16+ "Effect": "Allow",
17+ "Principal": {
18+ "AWS": "arn:aws:iam::123456789:root"
19+ },
20+ "Action": "kms:*",
21+ "Resource": "*"
22+ },
23+ {
24+ "Sid": "Allow access for Key Administrators",
25+ "Effect": "Allow",
26+ "Principal": {
27+ "AWS": [
28+ "arn:aws:iam::123456789:user/plakhera"
29+ ]
30+ },
31+ "Action": [
32+ "kms:Create*",
33+ "kms:Describe*",
34+ "kms:Enable*",
35+ "kms:List*",
36+ "kms:Put*",
37+ "kms:Update*",
38+ "kms:Revoke*",
39+ "kms:Disable*",
40+ "kms:Get*",
41+ "kms:Delete*",
42+ "kms:TagResource",
43+ "kms:UntagResource",
44+ "kms:ScheduleKeyDeletion",
45+ "kms:CancelKeyDeletion"
46+ ],
47+ "Resource": "*"
48+ },
49+ {
50+ "Sid": "Allow use of the key",
51+ "Effect": "Allow",
52+ "Principal": {
53+ "AWS": [
54+ "arn:aws:iam::123456789:user/plakhera"
55+
56+ ]
57+ },
58+ "Action": [
59+ "kms:Encrypt",
60+ "kms:Decrypt",
61+ "kms:ReEncrypt*",
62+ "kms:GenerateDataKey*",
63+ "kms:DescribeKey"
64+ ],
65+ "Resource": "*"
66+ },
67+ {
68+ "Sid": "Allow attachment of persistent resources",
69+ "Effect": "Allow",
70+ "Principal": {
71+ "AWS": [
72+ "arn:aws:iam::123456789:user/plakhera",
73+
74+ ]
75+ },
76+ "Action": [
77+ "kms:CreateGrant",
78+ "kms:ListGrants",
79+ "kms:RevokeGrant"
80+ ],
81+ "Resource": "*"
82+ }
83+ ]
84+ }
85+ EOF
86+ }
87+
88+ resource "aws_kms_alias" "smc-kms-alias" {
89+ target_key_id = " ${ aws_kms_key . my-kms-key . key_id } "
90+ name = " alias/my-terraform-final-encryption-key"
91+ }
You can’t perform that action at this time.
0 commit comments