Skip to content

Commit 571e4e7

Browse files
authored
chore: Use # for comments. It's the recommended way to start comment and it's more idiomatic (#1079)
1 parent 127a3a8 commit 571e4e7

File tree

4 files changed

+34
-31
lines changed

4 files changed

+34
-31
lines changed

examples/launch_templates_with_managed_node_groups/disk_encryption_policy.tf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
// if you have used ASGs before, that role got auto-created already and you need to import to TF state
1+
# if you have used ASGs before, that role got auto-created already and you need to import to TF state
22
resource "aws_iam_service_linked_role" "autoscaling" {
33
aws_service_name = "autoscaling.amazonaws.com"
44
description = "Default Service-Linked Role enables access to AWS Services and Resources used or managed by Auto Scaling"
55
}
66

77
data "aws_caller_identity" "current" {}
88

9-
// This policy is required for the KMS key used for EKS root volumes, so the cluster is allowed to enc/dec/attach encrypted EBS volumes
9+
# This policy is required for the KMS key used for EKS root volumes, so the cluster is allowed to enc/dec/attach encrypted EBS volumes
1010
data "aws_iam_policy_document" "ebs_decryption" {
11-
// copy of default KMS policy that lets you manage it
11+
# Copy of default KMS policy that lets you manage it
1212
statement {
1313
sid = "Enable IAM User Permissions"
1414
effect = "Allow"
@@ -25,16 +25,16 @@ data "aws_iam_policy_document" "ebs_decryption" {
2525
resources = ["*"]
2626
}
2727

28-
// required for EKS
28+
# Required for EKS
2929
statement {
3030
sid = "Allow service-linked role use of the CMK"
3131
effect = "Allow"
3232

3333
principals {
3434
type = "AWS"
3535
identifiers = [
36-
"arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling", // required for the ASG to manage encrypted volumes for nodes
37-
module.eks.cluster_iam_role_arn, // required for the cluster / persistentvolume-controller to create encrypted PVCs
36+
"arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling", # required for the ASG to manage encrypted volumes for nodes
37+
module.eks.cluster_iam_role_arn, # required for the cluster / persistentvolume-controller to create encrypted PVCs
3838
]
3939
}
4040

@@ -56,8 +56,8 @@ data "aws_iam_policy_document" "ebs_decryption" {
5656
principals {
5757
type = "AWS"
5858
identifiers = [
59-
"arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling", // required for the ASG to manage encrypted volumes for nodes
60-
module.eks.cluster_iam_role_arn, // required for the cluster / persistentvolume-controller to create encrypted PVCs
59+
"arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling", # required for the ASG to manage encrypted volumes for nodes
60+
module.eks.cluster_iam_role_arn, # required for the cluster / persistentvolume-controller to create encrypted PVCs
6161
]
6262
}
6363

examples/launch_templates_with_managed_node_groups/launchtemplate.tf

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ data "template_file" "launch_template_userdata" {
1111
}
1212
}
1313

14-
// this is based on the LT that EKS would create if no custom one is specified (aws ec2 describe-launch-template-versions --launch-template-id xxx)
15-
// there are several more options one could set but you probably dont need to modify them
16-
// you can take the default and add your custom AMI and/or custom tags
17-
//
18-
// Trivia: AWS transparently creates a copy of your LaunchTemplate and actually uses that copy then for the node group. If you DONT use a custom AMI,
19-
// then the default user-data for bootstrapping a cluster is merged in the copy.
14+
# This is based on the LT that EKS would create if no custom one is specified (aws ec2 describe-launch-template-versions --launch-template-id xxx)
15+
# there are several more options one could set but you probably dont need to modify them
16+
# you can take the default and add your custom AMI and/or custom tags
17+
#
18+
# Trivia: AWS transparently creates a copy of your LaunchTemplate and actually uses that copy then for the node group. If you DONT use a custom AMI,
19+
# then the default user-data for bootstrapping a cluster is merged in the copy.
2020
resource "aws_launch_template" "default" {
2121
name_prefix = "eks-example-"
2222
description = "Default Launch-Template"
@@ -29,10 +29,11 @@ resource "aws_launch_template" "default" {
2929
volume_size = 100
3030
volume_type = "gp2"
3131
delete_on_termination = true
32-
//encrypted = true
33-
// enable this if you want to encrypt your node root volumes with a KMS/CMK. encryption of PVCs is handled via k8s StorageClass tho
34-
// you also need to attach data.aws_iam_policy_document.ebs_decryption.json from the disk_encryption_policy.tf to the KMS/CMK key then !!
35-
//kms_key_id = var.kms_key_arn
32+
# encrypted = true
33+
34+
# Enable this if you want to encrypt your node root volumes with a KMS/CMK. encryption of PVCs is handled via k8s StorageClass tho
35+
# you also need to attach data.aws_iam_policy_document.ebs_decryption.json from the disk_encryption_policy.tf to the KMS/CMK key then !!
36+
# kms_key_id = var.kms_key_arn
3637
}
3738
}
3839

@@ -48,19 +49,20 @@ resource "aws_launch_template" "default" {
4849
security_groups = [module.eks.worker_security_group_id]
4950
}
5051

51-
//image_id = var.ami_id // if you want to use a custom AMI
52+
# if you want to use a custom AMI
53+
# image_id = var.ami_id
5254

53-
// if you use a custom AMI, you need to supply via user-data, the bootstrap script as EKS DOESNT merge its managed user-data then
54-
// you can add more than the minimum code you see in the template, e.g. install SSM agent, see https://github.com/aws/containers-roadmap/issues/593#issuecomment-577181345
55-
//
56-
// (optionally you can use https://registry.terraform.io/providers/hashicorp/cloudinit/latest/docs/data-sources/cloudinit_config to render the script, example: https://github.com/terraform-aws-modules/terraform-aws-eks/pull/997#issuecomment-705286151)
55+
# If you use a custom AMI, you need to supply via user-data, the bootstrap script as EKS DOESNT merge its managed user-data then
56+
# you can add more than the minimum code you see in the template, e.g. install SSM agent, see https://github.com/aws/containers-roadmap/issues/593#issuecomment-577181345
57+
#
58+
# (optionally you can use https://registry.terraform.io/providers/hashicorp/cloudinit/latest/docs/data-sources/cloudinit_config to render the script, example: https://github.com/terraform-aws-modules/terraform-aws-eks/pull/997#issuecomment-705286151)
5759

58-
// user_data = base64encode(
59-
// data.template_file.launch_template_userdata.rendered,
60-
// )
60+
# user_data = base64encode(
61+
# data.template_file.launch_template_userdata.rendered,
62+
# )
6163

6264

63-
// supplying custom tags to EKS instances is another use-case for LaunchTemplates
65+
# Supplying custom tags to EKS instances is another use-case for LaunchTemplates
6466
tag_specifications {
6567
resource_type = "instance"
6668

@@ -69,7 +71,7 @@ resource "aws_launch_template" "default" {
6971
}
7072
}
7173

72-
// supplying custom tags to EKS instances root volumes is another use-case for LaunchTemplates. (doesnt add tags to dynamically provisioned volumes via PVC tho)
74+
# Supplying custom tags to EKS instances root volumes is another use-case for LaunchTemplates. (doesnt add tags to dynamically provisioned volumes via PVC tho)
7375
tag_specifications {
7476
resource_type = "volume"
7577

@@ -78,7 +80,7 @@ resource "aws_launch_template" "default" {
7880
}
7981
}
8082

81-
// tag the LT itself
83+
# Tag the LT itself
8284
tags = {
8385
CustomTag = "EKS example"
8486
}

examples/launch_templates_with_managed_node_groups/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module "vpc" {
6565
enable_dns_hostnames = true
6666

6767
private_subnet_tags = {
68-
"kubernetes.io/cluster/${local.cluster_name}" = "shared" // EKS adds this and TF would want to remove then later
68+
"kubernetes.io/cluster/${local.cluster_name}" = "shared" # EKS adds this and TF would want to remove then later
6969
}
7070
}
7171

examples/launch_templates_with_managed_node_groups/variables.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ variable "region" {
33
}
44

55
variable "instance_type" {
6-
default = "t3.small" // smallest recommended, where ~1.1Gb of 2Gb memory is available for the Kubernetes pods after ‘warming up’ Docker, Kubelet, and OS
6+
# Smallest recommended, where ~1.1Gb of 2Gb memory is available for the Kubernetes pods after ‘warming up’ Docker, Kubelet, and OS
7+
default = "t3.small"
78
type = string
89
}
910

0 commit comments

Comments
 (0)