mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-03-13 05:45:12 +01:00
feat: Add support for creating KMS key for cluster secret encryption (#2121)
* feat: Add support for creating KMS key for cluster secret encryption * fix: Update naming scheme to include `kms_`
This commit is contained in:
@@ -61,7 +61,6 @@ Note that this example may create resources which cost money. Run `terraform des
|
||||
|
||||
| Name | Type |
|
||||
|------|------|
|
||||
| [aws_kms_key.eks](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource |
|
||||
| [aws_security_group.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
|
||||
|
||||
## Inputs
|
||||
@@ -92,6 +91,9 @@ No inputs.
|
||||
| <a name="output_eks_managed_node_groups"></a> [eks\_managed\_node\_groups](#output\_eks\_managed\_node\_groups) | Map of attribute maps for all EKS managed node groups created |
|
||||
| <a name="output_eks_managed_node_groups_autoscaling_group_names"></a> [eks\_managed\_node\_groups\_autoscaling\_group\_names](#output\_eks\_managed\_node\_groups\_autoscaling\_group\_names) | List of the autoscaling group names created by EKS managed node groups |
|
||||
| <a name="output_fargate_profiles"></a> [fargate\_profiles](#output\_fargate\_profiles) | Map of attribute maps for all EKS Fargate Profiles created |
|
||||
| <a name="output_kms_key_arn"></a> [kms\_key\_arn](#output\_kms\_key\_arn) | The Amazon Resource Name (ARN) of the key |
|
||||
| <a name="output_kms_key_id"></a> [kms\_key\_id](#output\_kms\_key\_id) | The globally unique identifier for the key |
|
||||
| <a name="output_kms_key_policy"></a> [kms\_key\_policy](#output\_kms\_key\_policy) | The IAM resource policy set on the key |
|
||||
| <a name="output_oidc_provider"></a> [oidc\_provider](#output\_oidc\_provider) | The OpenID Connect identity provider (issuer URL without leading `https://`) |
|
||||
| <a name="output_oidc_provider_arn"></a> [oidc\_provider\_arn](#output\_oidc\_provider\_arn) | The ARN of the OIDC Provider if `enable_irsa = true` |
|
||||
| <a name="output_self_managed_node_groups"></a> [self\_managed\_node\_groups](#output\_self\_managed\_node\_groups) | Map of attribute maps for all self managed node groups created |
|
||||
|
||||
@@ -52,10 +52,13 @@ module "eks" {
|
||||
}
|
||||
}
|
||||
|
||||
# Encryption key
|
||||
create_kms_key = true
|
||||
cluster_encryption_config = [{
|
||||
provider_key_arn = aws_kms_key.eks.arn
|
||||
resources = ["secrets"]
|
||||
resources = ["secrets"]
|
||||
}]
|
||||
kms_key_deletion_window_in_days = 7
|
||||
enable_kms_key_rotation = true
|
||||
|
||||
vpc_id = module.vpc.vpc_id
|
||||
subnet_ids = module.vpc.private_subnets
|
||||
@@ -372,11 +375,3 @@ resource "aws_security_group" "additional" {
|
||||
|
||||
tags = local.tags
|
||||
}
|
||||
|
||||
resource "aws_kms_key" "eks" {
|
||||
description = "EKS Secret Encryption Key"
|
||||
deletion_window_in_days = 7
|
||||
enable_key_rotation = true
|
||||
|
||||
tags = local.tags
|
||||
}
|
||||
|
||||
@@ -42,6 +42,25 @@ output "cluster_security_group_id" {
|
||||
value = module.eks.cluster_security_group_id
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# KMS Key
|
||||
################################################################################
|
||||
|
||||
output "kms_key_arn" {
|
||||
description = "The Amazon Resource Name (ARN) of the key"
|
||||
value = module.eks.kms_key_arn
|
||||
}
|
||||
|
||||
output "kms_key_id" {
|
||||
description = "The globally unique identifier for the key"
|
||||
value = module.eks.kms_key_id
|
||||
}
|
||||
|
||||
output "kms_key_policy" {
|
||||
description = "The IAM resource policy set on the key"
|
||||
value = module.eks.kms_key_policy
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Security Group
|
||||
################################################################################
|
||||
|
||||
Reference in New Issue
Block a user