Skip to content

Commit

Permalink
feat(ssm): custom ami id (#5)
Browse files Browse the repository at this point in the history
* feat(fis): disabled vpc endpoints for fis example

* feat(ssm): custom ami id
  • Loading branch information
Young-ook authored May 10, 2021
1 parent b277bb9 commit e05354e
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 21 deletions.
20 changes: 20 additions & 0 deletions examples/bastion/tc3.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name = "ssm-tc3-ami"
tags = {
env = "dev"
test = "tc3"
}
aws_region = "ap-northeast-2"
azs = ["ap-northeast-2a", "ap-northeast-2b", "ap-northeast-2c"]
cidr = "10.1.0.0/16"
enable_igw = false
enable_ngw = false
node_groups = [
{
name = "default"
min_size = 1
max_size = 1
desired_size = 1
instance_type = "t3.small"
image_id = "ami-04a18ed8b7b44aced" # Windows Server 2019 English Full Base (ap-northeast-2)
}
]
17 changes: 9 additions & 8 deletions examples/fis/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ provider "aws" {

# vpc
module "vpc" {
source = "Young-ook/spinnaker/aws//modules/spinnaker-aware-aws-vpc"
name = var.name
tags = var.tags
azs = var.azs
cidr = var.cidr
enable_igw = var.enable_igw
enable_ngw = var.enable_ngw
single_ngw = var.single_ngw
source = "Young-ook/spinnaker/aws//modules/spinnaker-aware-aws-vpc"
name = var.name
tags = var.tags
azs = var.azs
cidr = var.cidr
vpc_endpoint_config = var.vpc_endpoint_config
enable_igw = var.enable_igw
enable_ngw = var.enable_ngw
single_ngw = var.single_ngw
}

# ec2
Expand Down
13 changes: 7 additions & 6 deletions examples/fis/tc1.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ tags = {
env = "prod"
test = "tc1"
}
aws_region = "ap-northeast-2"
azs = ["ap-northeast-2a", "ap-northeast-2b", "ap-northeast-2c"]
cidr = "10.1.0.0/16"
enable_igw = true
enable_ngw = true
single_ngw = true
aws_region = "ap-northeast-2"
azs = ["ap-northeast-2a", "ap-northeast-2b", "ap-northeast-2c"]
cidr = "10.1.0.0/16"
vpc_endpoint_config = []
enable_igw = true
enable_ngw = true
single_ngw = true
node_groups = [
{
name = "default"
Expand Down
13 changes: 7 additions & 6 deletions examples/fis/tc2.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ tags = {
env = "dev"
test = "tc2"
}
aws_region = "ap-northeast-2"
azs = ["ap-northeast-2a", "ap-northeast-2b", "ap-northeast-2c"]
cidr = "10.1.0.0/16"
enable_igw = true
enable_ngw = true
single_ngw = true
aws_region = "ap-northeast-2"
azs = ["ap-northeast-2a", "ap-northeast-2b", "ap-northeast-2c"]
cidr = "10.1.0.0/16"
vpc_endpoint_config = []
enable_igw = true
enable_ngw = true
single_ngw = true
node_groups = [
{
name = "default"
Expand Down
6 changes: 6 additions & 0 deletions examples/fis/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ variable "azs" {
default = ["us-east-1a", "us-east-1b", "us-east-1c"]
}

variable "vpc_endpoint_config" {
description = "A list of vpc endpoint configurations"
type = list
default = null
}

variable "private_subnets" {
description = "A list of CIDRs for private subnets"
type = list(string)
Expand Down
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ resource "aws_launch_template" "asg" {
for_each = { for ng in var.node_groups : ng.name => ng }
name = join("-", [local.name, each.key])
tags = merge(local.default-tags, var.tags)
image_id = data.aws_ami.al2[each.key].id
image_id = lookup(each.value, "image_id", data.aws_ami.al2[each.key].id)
user_data = base64encode(data.template_file.boot[each.key].rendered)
instance_type = lookup(each.value, "instance_type", "t3.medium")
key_name = lookup(each.value, "key_name", null)

iam_instance_profile {
arn = aws_iam_instance_profile.asg.arn
Expand Down

0 comments on commit e05354e

Please sign in to comment.