diff --git a/.gitignore b/.gitignore index 5e7c19218..b62d81763 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ build-harness *.tfstate.* .idea *.iml +.viminfo +.terraform.d diff --git a/aws/kops/Makefile b/aws/kops/Makefile new file mode 100644 index 000000000..4c52832b4 --- /dev/null +++ b/aws/kops/Makefile @@ -0,0 +1,15 @@ +## Initialize terraform remote state +init: + init-terraform + +## Show terraform plan for this project +plan: init + terraform plan + +## Apply terraform plan for this project +apply: init + terraform apply $(TERRAFORM_ARGS) + +## Destroy terraform project +destroy: init + terraform destroy $(TERRAFORM_ARGS) diff --git a/aws/kops/main.tf b/aws/kops/main.tf index 6c0615f54..b676e54d3 100644 --- a/aws/kops/main.tf +++ b/aws/kops/main.tf @@ -18,6 +18,12 @@ variable "stage" { description = "Stage (e.g. `prod`, `dev`, `staging`)" } +variable "name" { + type = "string" + description = "Name (e.g. `kops`)" + default = "kops" +} + variable "region" { type = "string" description = "AWS region" @@ -28,6 +34,24 @@ variable "zone_name" { description = "DNS zone name" } +variable "domain_enabled" { + type = "string" + description = "Enable DNS Zone creation for kops" + default = "true" +} + +variable "force_destroy" { + type = "string" + description = "A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without errors. These objects are not recoverable." + default = "false" +} + +variable "ssh_public_key_path" { + type = "string" + description = "SSH public key path to write master public/private key pair for cluster" + default = "/secrets/tf/ssh" +} + provider "aws" { assume_role { role_arn = "${var.aws_assume_role_arn}" @@ -35,13 +59,16 @@ provider "aws" { } module "kops_state_backend" { - source = "git::https://github.com/cloudposse/terraform-aws-kops-state-backend.git?ref=tags/0.1.3" + source = "git::https://github.com/cloudposse/terraform-aws-kops-state-backend.git?ref=tags/0.1.5" namespace = "${var.namespace}" stage = "${var.stage}" - name = "kops-state" + name = "${var.name}" + attributes = ["state"] cluster_name = "${var.region}" parent_zone_name = "${var.zone_name}" zone_name = "$${name}.$${parent_zone_name}" + domain_enabled = "${var.domain_enabled}" + force_destroy = "${var.force_destroy}" region = "${var.region}" } @@ -49,7 +76,8 @@ module "ssh_key_pair" { source = "git::https://github.com/cloudposse/terraform-aws-key-pair.git?ref=tags/0.2.3" namespace = "${var.namespace}" stage = "${var.stage}" - name = "kops-${var.region}" - ssh_public_key_path = "/secrets/tf/ssh" + name = "${var.name}" + attributes = ["${var.region}"] + ssh_public_key_path = "${var.ssh_public_key_path}" generate_ssh_key = "true" } diff --git a/aws/kops/outputs.tf b/aws/kops/outputs.tf index 46abd33e9..5994ede50 100644 --- a/aws/kops/outputs.tf +++ b/aws/kops/outputs.tf @@ -38,6 +38,6 @@ output "ssh_key_name" { value = "${module.ssh_key_pair.key_name}" } -output "shh_public_key" { +output "ssh_public_key" { value = "${module.ssh_key_pair.public_key}" } diff --git a/aws/kops/terraform.tfvars.example b/aws/kops/terraform.tfvars.example index 16db64d2b..b50b3fec6 100644 --- a/aws/kops/terraform.tfvars.example +++ b/aws/kops/terraform.tfvars.example @@ -2,3 +2,4 @@ namespace="cp" stage="staging" region="us-west-2" zone_name="us-west-2.cloudposse.co" +domain_enabled="true" diff --git a/codefresh.yml b/codefresh.yml index e57a1fbb4..03fd3b770 100644 --- a/codefresh.yml +++ b/codefresh.yml @@ -6,7 +6,7 @@ steps: title: Init variables image: alpine commands: - - cf_export BUILD_HARNESS_VERSION=0.5.5 + - cf_export BUILD_HARNESS_VERSION=0.7.0 - cf_export GIT_BRANCH=${{CF_BRANCH}} build_image: