Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1d5340f

Browse filesBrowse files
Terraform Code for KMS
1 parent c4e22a2 commit 1d5340f
Copy full SHA for 1d5340f

1 file changed

+91Lines changed: 91 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎kms/main.tf‎

Copy file name to clipboard
+91Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.