Created
June 3, 2019 16:30
-
-
Save cjbischoff/215519a2e94159c9b580afa73a1595e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# KMS.tf | |
resource "aws_kms_key" "kms_key" { | |
policy = <<POLICY | |
{ | |
"Version": "2012-10-17", | |
"Id": "${var.name}-key", | |
"Statement": [ | |
{ | |
"Sid": "Enable IAM User Permissions", | |
"Effect": "Allow", | |
"Principal": { | |
"AWS": "arn:aws:iam::${data.aws_caller_identity.current.account_id}:root" | |
}, | |
"Action": "kms:*", | |
"Resource": "*" | |
} | |
] | |
} | |
POLICY | |
} | |
resource "aws_kms_alias" "kms_key" { | |
name = "alias/${var.name}" | |
target_key_id = "${aws_kms_key.kms_key.id}" | |
} | |
# OUTPUT.tf | |
output "kms_key_arn" { | |
value = "${aws_kms_key.kms_key.arn}" | |
} | |
# VARIABLES.TF | |
variable "name" {} | |
data "aws_caller_identity" "current" {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment