Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add service linked role for KMS #1879

Merged
merged 2 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tf_files/aws/modules/squid_auto/cloud.tf
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,26 @@ resource "null_resource" "service_depends_on" {
}
}

# Create a new iam service linked role that we can grant access to KMS keys in other accounts
# Needed if we need to bring up custom AMI's that have been encrypted using a kms key
resource "aws_iam_service_linked_role" "squidautoscaling" {
aws_service_name = "autoscaling.amazonaws.com"
custom_suffix = "${var.env_vpc_name}"
}

# Remember to grant access to the account in the KMS key policy too
resource "aws_kms_grant" "kms" {
count = "${var.fips ? 1 : 0}"
name = "kms-cmk-eks"
key_id = "${var.fips_ami_kms}"
grantee_principal = "${aws_iam_service_linked_role.squidautoscaling.arn}"
operations = ["Encrypt", "Decrypt", "ReEncryptFrom", "ReEncryptTo", "GenerateDataKey", "GenerateDataKeyWithoutPlaintext", "DescribeKey", "CreateGrant"]
}

resource "aws_autoscaling_group" "squid_auto" {
count = "${var.deploy_ha_squid ? 1 : 0}"
name = "${var.env_squid_name}"
service_linked_role_arn = "${aws_iam_service_linked_role.squidautoscaling.arn}"
desired_capacity = "${var.cluster_desired_capasity}"
max_size = "${var.cluster_max_size}"
min_size = "${var.cluster_min_size}"
Expand Down
10 changes: 10 additions & 0 deletions tf_files/aws/modules/squid_auto/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,13 @@ variable "customer_id" {
variable "slack_webhook" {
default = ""
}

# the key that was used to encrypt the FIPS enabled AMI
# This is needed so ASG can decrypt the ami
variable "fips_ami_kms" {
default = "arn:aws:kms:us-east-1:707767160287:key/mrk-697897f040ef45b0aa3cebf38a916f99"
}

variable "fips" {
default = false
}