Skip to content

Commit

Permalink
Merge pull request #7 from SmartColumbusOS/common-512
Browse files Browse the repository at this point in the history
Common#512 Run terraform 0.12upgrade on repo
  • Loading branch information
ksmith-accenture authored Apr 1, 2021
2 parents d30f6fc + 0857d43 commit 9508b13
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "shared"]
path = shared
url = [email protected]:SmartColumbusOS/scos-tf-backends.git
15 changes: 6 additions & 9 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
library(
identifier: 'pipeline-lib@4.6.1',
identifier: 'pipeline-lib@4.8.0',
retriever: modernSCM([$class: 'GitSCMSource',
remote: 'https://github.com/SmartColumbusOS/pipeline-lib',
credentialsId: 'jenkins-github-user'])
Expand All @@ -26,25 +26,22 @@ node ('infrastructure') {
}

doStageIfMergedToMaster('Deploy to Staging') {
def environment = 'staging'
deployTo(environment: environment)
scos.applyAndPushGitHubTag(environment)
deployTo(environment: 'staging')
scos.applyAndPushGitHubTag('staging')
}

doStageIfRelease('Deploy to Production') {
def environment = 'prod'
deployTo(environment: environment)
scos.applyAndPushGitHubTag(environment)
deployTo(environment: 'prod')
scos.applyAndPushGitHubTag('prod')
}
}
}

def deployTo(params = [:]) {
def environment = params.get('environment')
if (environment == null) throw new IllegalArgumentException("environment must be specified")

def terraform = scos.terraform(environment)
sh "terraform init && terraform workspace new ${environment}"
terraform.init()
terraform.plan(terraform.defaultVarFile)
terraform.apply()
}
23 changes: 13 additions & 10 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
provider "aws" {
version = "1.39"
region = "${var.region}"
version = "~> 3.0"
region = var.region

assume_role {
role_arn = "${var.role_arn}"
role_arn = var.role_arn
}
}

data "terraform_remote_state" "env_remote_state" {
backend = "s3"
workspace = "${terraform.workspace}"
workspace = terraform.workspace

config {
bucket = "${var.alm_state_bucket_name}"
config = {
bucket = var.alm_state_bucket_name
key = "operating-system"
region = "us-east-2"
role_arn = "${var.alm_role_arn}"
role_arn = var.alm_role_arn
}
}

resource "local_file" "kubeconfig" {
filename = "${path.module}/outputs/kubeconfig"
content = "${data.terraform_remote_state.env_remote_state.eks_cluster_kubeconfig}"
content = data.terraform_remote_state.env_remote_state.outputs.eks_cluster_kubeconfig
}

resource "local_file" "helm_vars" {
Expand All @@ -34,6 +34,7 @@ services:
- hostname: "iam-master.${var.alm_dns_zone}"
name: ldap
EOF

}

resource "null_resource" "helm_deploy" {
Expand All @@ -49,12 +50,13 @@ helm repo update
helm upgrade --install external-services scdp/external-services --namespace=external-services \
--values ${local_file.helm_vars.filename}
EOF

}

triggers {
triggers = {
# Triggers a list of values that, when changed, will cause the resource to be recreated
# ${uuid()} will always be different thus always executing above local-exec
hack_that_always_forces_null_resources_to_execute = "${uuid()}"
hack_that_always_forces_null_resources_to_execute = uuid()
}
}

Expand All @@ -81,3 +83,4 @@ variable "alm_state_bucket_name" {
variable "alm_dns_zone" {
description = "DNS zone for alm"
}

1 change: 1 addition & 0 deletions shared
Submodule shared added at 48dd3c
4 changes: 4 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

terraform {
required_version = ">= 0.12"
}

0 comments on commit 9508b13

Please sign in to comment.