Compare commits

...

10 Commits

Author SHA1 Message Date
masterofmonkeys 2d7a519839 activate eu/us live stages. 2023-06-17 18:44:38 +02:00
masterofmonkeys 763645645c VSDSCP-275 - activate CA/Live API URL. 2023-06-17 18:22:49 +02:00
Sylvain Gibier f96adfa366 fix eu/prelive backend 2023-06-16 19:20:32 +02:00
Sylvain Gibier 902b76e6ad VSDSCP-212 - refactoring and enabling int/ all prelive stages. 2023-06-16 18:49:56 +02:00
Sylvain Gibier 0c65c5897c wip - jenkins de merde. 2023-06-16 16:50:35 +02:00
Sylvain Gibier 736fdb87af wip - jenkins de merde. 2023-06-16 16:25:36 +02:00
Sylvain Gibier b67d13b0ba wip - jenkins 2023-06-16 16:23:11 +02:00
Sylvain Gibier 07152a74ce wip - jenkins 2023-06-16 16:21:25 +02:00
Sylvain Gibier 23199ce0e4 wip - jenkins 2023-06-16 16:15:36 +02:00
Sylvain Gibier 7f62c0c68f wip - jenkins 2023-06-16 16:07:54 +02:00
28 changed files with 901 additions and 90 deletions

View File

@ -0,0 +1,113 @@
String cloud_provider = "aws"
String aws_region = "ca-north-1"
String default_stage = "live"
String aws_access_credentials = "vsds_${aws_region}_${default_stage}_infrastructure.automation.user"
String dynatrace_api_token_credentials = "api_token_dynatrace_${aws_region}_${default_stage}"
pipeline {
agent {
node {
label 'vsds-terraform'
}
}
environment {
GIT_SSH_COMMAND = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
AWS_ID = credentials("${aws_access_credentials}")
AWS_ACCESS_KEY_ID = "${env.AWS_ID_USR}"
AWS_SECRET_ACCESS_KEY = "${env.AWS_ID_PSW}"
AWS_REGION = "${aws_region}"
STAGE = "${default_stage}"
CLOUD_PROVIDER = "${cloud_provider}"
API_TOKEN = credentials("${dynatrace_api_token_credentials}")
TF_VAR_dt_api_token = "${env.API_TOKEN}"
}
options {
timestamps()
ansiColor('xterm')
disableConcurrentBuilds(abortPrevious: true)
timeout(time: 1, unit: 'HOURS')
}
stages {
stage('terraform init') {
steps {
sshagent(credentials: ['sofa-user-automation']) {
container('terraform') {
sh """
set -e
cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE}
terraform init
"""
}
}
}
}
stage('Terraform plan') {
steps {
sshagent(credentials: ['sofa-user-automation']) {
container('terraform') {
script {
env.PLAN_STATUS = sh(script: "cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE} && terraform plan -out=.terraform/plan.out -input=false -detailed-exitcode", returnStatus: true)
if (env.PLAN_STATUS == "1") {
currentBuild.result = "FAILURE"
error('Aborting the build.')
return
}
}
}
}
}
}
stage('Interactive') {
when {
allOf {
expression { env.PLAN_STATUS == "2" }
}
}
steps {
timeout(time: 15, unit: "MINUTES") {
input "Is this plan acceptable?"
milestone 1
}
}
}
stage("terraform apply") {
when {
allOf {
expression { env.PLAN_STATUS == "2" }
}
}
steps {
container('terraform') {
sshagent(credentials: ['sofa-user-automation']) {
script {
sh "cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE} "
sh("terraform apply -input=false .terraform/plan.out")
}
}
}
}
}
}
post {
always {
cleanWs()
script {
currentBuild.result = currentBuild.result ?: 'SUCCESS'
notifyBitbucket()
}
}
}
}

View File

@ -0,0 +1,21 @@
terraform {
required_providers {
dynatrace = {
version = "1.33.0"
source = "dynatrace-oss/dynatrace"
}
aws = {
source = "hashicorp/aws"
version = "5.1.0"
}
}
}
provider "aws" {
region = var.aws_region
}
provider "dynatrace" {
dt_env_url = var.dt_env_url
dt_api_token = var.dt_api_token
}

View File

@ -0,0 +1,3 @@
aws_region = "ca-north-1"
dt_env_url = "https://console.eu.mon.vsds.swarm.audi/e/558a3c22-84ba-4132-804e-e862f57a6eb1/api"

View File

@ -0,0 +1,11 @@
variable "aws_region" {
description = "The aws region to deploy in"
}
variable "dt_env_url" {
description = "Dynatrace Environment URL"
}
variable "dt_api_token" {
description = "Dynatrace API Token"
}

View File

@ -0,0 +1,113 @@
String cloud_provider = "aws"
String aws_region = "ca-north-1"
String default_stage = "prelive"
String aws_access_credentials = "vsds_${aws_region}_${default_stage}_infrastructure.automation.user"
String dynatrace_api_token_credentials = "api_token_dynatrace_${aws_region}_${default_stage}"
pipeline {
agent {
node {
label 'vsds-terraform'
}
}
environment {
GIT_SSH_COMMAND = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
AWS_ID = credentials("${aws_access_credentials}")
AWS_ACCESS_KEY_ID = "${env.AWS_ID_USR}"
AWS_SECRET_ACCESS_KEY = "${env.AWS_ID_PSW}"
AWS_REGION = "${aws_region}"
STAGE = "${default_stage}"
CLOUD_PROVIDER = "${cloud_provider}"
API_TOKEN = credentials("${dynatrace_api_token_credentials}")
TF_VAR_dt_api_token = "${env.API_TOKEN}"
}
options {
timestamps()
ansiColor('xterm')
disableConcurrentBuilds(abortPrevious: true)
timeout(time: 1, unit: 'HOURS')
}
stages {
stage('terraform init') {
steps {
sshagent(credentials: ['sofa-user-automation']) {
container('terraform') {
sh """
set -e
cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE}
terraform init
"""
}
}
}
}
stage('Terraform plan') {
steps {
sshagent(credentials: ['sofa-user-automation']) {
container('terraform') {
script {
env.PLAN_STATUS = sh(script: "cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE} && terraform plan -out=.terraform/plan.out -input=false -detailed-exitcode", returnStatus: true)
if (env.PLAN_STATUS == "1") {
currentBuild.result = "FAILURE"
error('Aborting the build.')
return
}
}
}
}
}
}
stage('Interactive') {
when {
allOf {
expression { env.PLAN_STATUS == "2" }
}
}
steps {
timeout(time: 15, unit: "MINUTES") {
input "Is this plan acceptable?"
milestone 1
}
}
}
stage("terraform apply") {
when {
allOf {
expression { env.PLAN_STATUS == "2" }
}
}
steps {
container('terraform') {
sshagent(credentials: ['sofa-user-automation']) {
script {
sh "cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE} "
sh("terraform apply -input=false .terraform/plan.out")
}
}
}
}
}
}
post {
always {
cleanWs()
script {
currentBuild.result = currentBuild.result ?: 'SUCCESS'
notifyBitbucket()
}
}
}
}

View File

@ -0,0 +1,21 @@
terraform {
required_providers {
dynatrace = {
version = "1.33.0"
source = "dynatrace-oss/dynatrace"
}
aws = {
source = "hashicorp/aws"
version = "5.1.0"
}
}
}
provider "aws" {
region = var.aws_region
}
provider "dynatrace" {
dt_env_url = var.dt_env_url
dt_api_token = var.dt_api_token
}

View File

@ -0,0 +1,3 @@
aws_region = "ca-north-1"
dt_env_url = "https://console.prelive.eu.mon.vsds.swarm.audi/e/307daede-db0a-4f56-90db-8953368c3d29/api"

View File

@ -0,0 +1,11 @@
variable "aws_region" {
description = "The aws region to deploy in"
}
variable "dt_env_url" {
description = "Dynatrace Environment URL"
}
variable "dt_api_token" {
description = "Dynatrace API Token"
}

View File

@ -1,8 +1,8 @@
String cloud_provider = "aws"
String aws_region = "eu-west-1"
String stage = "int"
String aws_access_credentials = "fdc_${aws_region}_${stage}_infrastructure.automation.user"
String dynatrace_api_toke_credentials = "api_token_dynatrace_${aws_region}_${stage}"
String default_stage = "int"
String aws_access_credentials = "fdc_${aws_region}_${default_stage}_infrastructure.automation.user"
String dynatrace_api_token_credentials = "api_token_dynatrace_${aws_region}_${default_stage}"
pipeline {
@ -20,10 +20,10 @@ pipeline {
AWS_SECRET_ACCESS_KEY = "${env.AWS_ID_PSW}"
AWS_REGION = "${aws_region}"
STAGE = "${stage}"
STAGE = "${default_stage}"
CLOUD_PROVIDER = "${cloud_provider}"
API_TOKEN = credentials("${dynatrace_api_toke_credentials}")
API_TOKEN = credentials("${dynatrace_api_token_credentials}")
TF_VAR_dt_api_token = "${env.API_TOKEN}"
}
@ -34,10 +34,8 @@ pipeline {
timeout(time: 1, unit: 'HOURS')
}
stages {
stage("terraform init") {
stage('terraform init') {
steps {
sshagent(credentials: ['sofa-user-automation']) {
container('terraform') {
@ -45,21 +43,70 @@ pipeline {
set -e
cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE}
terraform init
terraform fmt
"""
}
}
}
}
stage('Terraform plan') {
steps {
sshagent(credentials: ['sofa-user-automation']) {
container('terraform') {
script {
env.PLAN_STATUS = sh(script: "cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE} && terraform plan -out=.terraform/plan.out -input=false -detailed-exitcode", returnStatus: true)
if (env.PLAN_STATUS == "1") {
currentBuild.result = "FAILURE"
error('Aborting the build.')
return
}
}
}
}
}
}
stage('Interactive') {
when {
allOf {
expression { env.PLAN_STATUS == "2" }
}
}
steps {
timeout(time: 15, unit: "MINUTES") {
input "Is this plan acceptable?"
milestone 1
}
}
}
stage("terraform apply") {
when {
allOf {
expression { env.PLAN_STATUS == "2" }
}
}
steps {
container('terraform') {
sshagent(credentials: ['sofa-user-automation']) {
script {
sh "cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE} "
sh("terraform apply -input=false .terraform/plan.out")
}
}
}
}
}
}
post {
always {
cleanWs()
script {
currentBuild.result = currentBuild.result ?: 'SUCCESS'
notifyBitbucket(projectKey: 'packages')
notifyBitbucket()
}
}
}

View File

@ -0,0 +1,113 @@
String cloud_provider = "aws"
String aws_region = "eu-west-1"
String default_stage = "live"
String aws_access_credentials = "fdc_${aws_region}_${default_stage}_infrastructure.automation.user"
String dynatrace_api_token_credentials = "api_token_dynatrace_${aws_region}_${default_stage}"
pipeline {
agent {
node {
label 'vsds-terraform'
}
}
environment {
GIT_SSH_COMMAND = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
AWS_ID = credentials("${aws_access_credentials}")
AWS_ACCESS_KEY_ID = "${env.AWS_ID_USR}"
AWS_SECRET_ACCESS_KEY = "${env.AWS_ID_PSW}"
AWS_REGION = "${aws_region}"
STAGE = "${default_stage}"
CLOUD_PROVIDER = "${cloud_provider}"
API_TOKEN = credentials("${dynatrace_api_token_credentials}")
TF_VAR_dt_api_token = "${env.API_TOKEN}"
}
options {
timestamps()
ansiColor('xterm')
disableConcurrentBuilds(abortPrevious: true)
timeout(time: 1, unit: 'HOURS')
}
stages {
stage('terraform init') {
steps {
sshagent(credentials: ['sofa-user-automation']) {
container('terraform') {
sh """
set -e
cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE}
terraform init
"""
}
}
}
}
stage('Terraform plan') {
steps {
sshagent(credentials: ['sofa-user-automation']) {
container('terraform') {
script {
env.PLAN_STATUS = sh(script: "cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE} && terraform plan -out=.terraform/plan.out -input=false -detailed-exitcode", returnStatus: true)
if (env.PLAN_STATUS == "1") {
currentBuild.result = "FAILURE"
error('Aborting the build.')
return
}
}
}
}
}
}
stage('Interactive') {
when {
allOf {
expression { env.PLAN_STATUS == "2" }
}
}
steps {
timeout(time: 15, unit: "MINUTES") {
input "Is this plan acceptable?"
milestone 1
}
}
}
stage("terraform apply") {
when {
allOf {
expression { env.PLAN_STATUS == "2" }
}
}
steps {
container('terraform') {
sshagent(credentials: ['sofa-user-automation']) {
script {
sh "cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE} "
sh("terraform apply -input=false .terraform/plan.out")
}
}
}
}
}
}
post {
always {
cleanWs()
script {
currentBuild.result = currentBuild.result ?: 'SUCCESS'
notifyBitbucket()
}
}
}
}

View File

@ -0,0 +1,21 @@
terraform {
required_providers {
dynatrace = {
version = "1.33.0"
source = "dynatrace-oss/dynatrace"
}
aws = {
source = "hashicorp/aws"
version = "5.1.0"
}
}
}
provider "aws" {
region = var.aws_region
}
provider "dynatrace" {
dt_env_url = var.dt_env_url
dt_api_token = var.dt_api_token
}

View File

@ -0,0 +1,3 @@
aws_region = "eu-west-1"
dt_env_url = "https://console.eu.mon.vsds.swarm.audi/e/3c8c4119-bfa9-420a-b590-479c543e2f05/api"

View File

@ -0,0 +1,11 @@
variable "aws_region" {
description = "The aws region to deploy in"
}
variable "dt_env_url" {
description = "Dynatrace Environment URL"
}
variable "dt_api_token" {
description = "Dynatrace API Token"
}

View File

@ -0,0 +1,113 @@
String cloud_provider = "aws"
String aws_region = "eu-west-1"
String default_stage = "prelive"
String aws_access_credentials = "fdc_${aws_region}_${default_stage}_infrastructure.automation.user"
String dynatrace_api_token_credentials = "api_token_dynatrace_${aws_region}_${default_stage}"
pipeline {
agent {
node {
label 'vsds-terraform'
}
}
environment {
GIT_SSH_COMMAND = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
AWS_ID = credentials("${aws_access_credentials}")
AWS_ACCESS_KEY_ID = "${env.AWS_ID_USR}"
AWS_SECRET_ACCESS_KEY = "${env.AWS_ID_PSW}"
AWS_REGION = "${aws_region}"
STAGE = "${default_stage}"
CLOUD_PROVIDER = "${cloud_provider}"
API_TOKEN = credentials("${dynatrace_api_token_credentials}")
TF_VAR_dt_api_token = "${env.API_TOKEN}"
}
options {
timestamps()
ansiColor('xterm')
disableConcurrentBuilds(abortPrevious: true)
timeout(time: 1, unit: 'HOURS')
}
stages {
stage('terraform init') {
steps {
sshagent(credentials: ['sofa-user-automation']) {
container('terraform') {
sh """
set -e
cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE}
terraform init
"""
}
}
}
}
stage('Terraform plan') {
steps {
sshagent(credentials: ['sofa-user-automation']) {
container('terraform') {
script {
env.PLAN_STATUS = sh(script: "cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE} && terraform plan -out=.terraform/plan.out -input=false -detailed-exitcode", returnStatus: true)
if (env.PLAN_STATUS == "1") {
currentBuild.result = "FAILURE"
error('Aborting the build.')
return
}
}
}
}
}
}
stage('Interactive') {
when {
allOf {
expression { env.PLAN_STATUS == "2" }
}
}
steps {
timeout(time: 15, unit: "MINUTES") {
input "Is this plan acceptable?"
milestone 1
}
}
}
stage("terraform apply") {
when {
allOf {
expression { env.PLAN_STATUS == "2" }
}
}
steps {
container('terraform') {
sshagent(credentials: ['sofa-user-automation']) {
script {
sh "cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE} "
sh("terraform apply -input=false .terraform/plan.out")
}
}
}
}
}
}
post {
always {
cleanWs()
script {
currentBuild.result = currentBuild.result ?: 'SUCCESS'
notifyBitbucket()
}
}
}
}

View File

@ -4,7 +4,7 @@ terraform {
key = "dynatrace/configuration.tfstate"
region = "eu-west-1"
encrypt = true
dynamodb_table = "fdc-eu-west-1-live-tfstate-lock"
dynamodb_table = "fdc-eu-west-1-prelive-tfstate-lock"
kms_key_id = "arn:aws:kms:eu-west-1:626466754332:key/8edf34f3-ac75-4515-b2da-f784e425c87b"
}
}

View File

@ -1,3 +0,0 @@
resource "dynatrace_audit_log" "test" {
enabled = false
}

View File

@ -1,7 +1,7 @@
terraform {
required_providers {
dynatrace = {
version = "1.31.0"
version = "1.33.0"
source = "dynatrace-oss/dynatrace"
}
aws = {
@ -13,4 +13,9 @@ terraform {
provider "aws" {
region = var.aws_region
}
}
provider "dynatrace" {
dt_env_url = var.dt_env_url
dt_api_token = var.dt_api_token
}

View File

@ -1,13 +1,3 @@
stack = "acdc"
stage = "prelive"
name = "dynatrace-prelive"
aws_region = "eu-west-1"
tags = {
"Managed_By" : "NTT_team"
}
kms = {
"s3" = "arn:aws:kms:eu-west-1:248567303878:key/8d860956-4033-4782-ab30-6cb84b31964e"
}
dt_env_url = "https://console.prelive.eu.mon.vsds.swarm.audi/e/dfe67e08-75f1-4c0f-9433-16af192faf88/api"

View File

@ -2,29 +2,10 @@ variable "aws_region" {
description = "The aws region to deploy in"
}
variable "name" {
description = "Name to be used on all the resources as identifier"
type = string
default = ""
variable "dt_env_url" {
description = "Dynatrace Environment URL"
}
variable "stack" {
description = "Environment stack"
default = "vsds"
variable "dt_api_token" {
description = "Dynatrace API Token"
}
variable "stage" {
description = "Environment stage"
}
variable "tags" {
description = "A map of tags to add to all resources"
type = map(string)
default = {}
}
variable "kms" {
description = "A map of kms keys to be used for any resources."
type = map(string)
default = {}
}

View File

@ -0,0 +1,113 @@
String cloud_provider = "aws"
String aws_region = "us-east-1"
String default_stage = "live"
String aws_access_credentials = "fdc_${aws_region}_${default_stage}_infrastructure.automation.user"
String dynatrace_api_token_credentials = "api_token_dynatrace_${aws_region}_${default_stage}"
pipeline {
agent {
node {
label 'vsds-terraform'
}
}
environment {
GIT_SSH_COMMAND = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
AWS_ID = credentials("${aws_access_credentials}")
AWS_ACCESS_KEY_ID = "${env.AWS_ID_USR}"
AWS_SECRET_ACCESS_KEY = "${env.AWS_ID_PSW}"
AWS_REGION = "${aws_region}"
STAGE = "${default_stage}"
CLOUD_PROVIDER = "${cloud_provider}"
API_TOKEN = credentials("${dynatrace_api_token_credentials}")
TF_VAR_dt_api_token = "${env.API_TOKEN}"
}
options {
timestamps()
ansiColor('xterm')
disableConcurrentBuilds(abortPrevious: true)
timeout(time: 1, unit: 'HOURS')
}
stages {
stage('terraform init') {
steps {
sshagent(credentials: ['sofa-user-automation']) {
container('terraform') {
sh """
set -e
cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE}
terraform init
"""
}
}
}
}
stage('Terraform plan') {
steps {
sshagent(credentials: ['sofa-user-automation']) {
container('terraform') {
script {
env.PLAN_STATUS = sh(script: "cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE} && terraform plan -out=.terraform/plan.out -input=false -detailed-exitcode", returnStatus: true)
if (env.PLAN_STATUS == "1") {
currentBuild.result = "FAILURE"
error('Aborting the build.')
return
}
}
}
}
}
}
stage('Interactive') {
when {
allOf {
expression { env.PLAN_STATUS == "2" }
}
}
steps {
timeout(time: 15, unit: "MINUTES") {
input "Is this plan acceptable?"
milestone 1
}
}
}
stage("terraform apply") {
when {
allOf {
expression { env.PLAN_STATUS == "2" }
}
}
steps {
container('terraform') {
sshagent(credentials: ['sofa-user-automation']) {
script {
sh "cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE} "
sh("terraform apply -input=false .terraform/plan.out")
}
}
}
}
}
}
post {
always {
cleanWs()
script {
currentBuild.result = currentBuild.result ?: 'SUCCESS'
notifyBitbucket()
}
}
}
}

View File

@ -0,0 +1,21 @@
terraform {
required_providers {
dynatrace = {
version = "1.33.0"
source = "dynatrace-oss/dynatrace"
}
aws = {
source = "hashicorp/aws"
version = "5.1.0"
}
}
}
provider "aws" {
region = var.aws_region
}
provider "dynatrace" {
dt_env_url = var.dt_env_url
dt_api_token = var.dt_api_token
}

View File

@ -0,0 +1,3 @@
aws_region = "us-east-1"
dt_env_url = "https://console.eu.mon.vsds.swarm.audi/e/bd72f2c1-7614-44cc-870a-77ffc2d3ce35/api"

View File

@ -0,0 +1,11 @@
variable "aws_region" {
description = "The aws region to deploy in"
}
variable "dt_env_url" {
description = "Dynatrace Environment URL"
}
variable "dt_api_token" {
description = "Dynatrace API Token"
}

View File

@ -0,0 +1,113 @@
String cloud_provider = "aws"
String aws_region = "us-east-1"
String default_stage = "prelive"
String aws_access_credentials = "fdc_${aws_region}_${default_stage}_infrastructure.automation.user"
String dynatrace_api_token_credentials = "api_token_dynatrace_${aws_region}_${default_stage}"
pipeline {
agent {
node {
label 'vsds-terraform'
}
}
environment {
GIT_SSH_COMMAND = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
AWS_ID = credentials("${aws_access_credentials}")
AWS_ACCESS_KEY_ID = "${env.AWS_ID_USR}"
AWS_SECRET_ACCESS_KEY = "${env.AWS_ID_PSW}"
AWS_REGION = "${aws_region}"
STAGE = "${default_stage}"
CLOUD_PROVIDER = "${cloud_provider}"
API_TOKEN = credentials("${dynatrace_api_token_credentials}")
TF_VAR_dt_api_token = "${env.API_TOKEN}"
}
options {
timestamps()
ansiColor('xterm')
disableConcurrentBuilds(abortPrevious: true)
timeout(time: 1, unit: 'HOURS')
}
stages {
stage('terraform init') {
steps {
sshagent(credentials: ['sofa-user-automation']) {
container('terraform') {
sh """
set -e
cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE}
terraform init
"""
}
}
}
}
stage('Terraform plan') {
steps {
sshagent(credentials: ['sofa-user-automation']) {
container('terraform') {
script {
env.PLAN_STATUS = sh(script: "cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE} && terraform plan -out=.terraform/plan.out -input=false -detailed-exitcode", returnStatus: true)
if (env.PLAN_STATUS == "1") {
currentBuild.result = "FAILURE"
error('Aborting the build.')
return
}
}
}
}
}
}
stage('Interactive') {
when {
allOf {
expression { env.PLAN_STATUS == "2" }
}
}
steps {
timeout(time: 15, unit: "MINUTES") {
input "Is this plan acceptable?"
milestone 1
}
}
}
stage("terraform apply") {
when {
allOf {
expression { env.PLAN_STATUS == "2" }
}
}
steps {
container('terraform') {
sshagent(credentials: ['sofa-user-automation']) {
script {
sh "cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE} "
sh("terraform apply -input=false .terraform/plan.out")
}
}
}
}
}
}
post {
always {
cleanWs()
script {
currentBuild.result = currentBuild.result ?: 'SUCCESS'
notifyBitbucket()
}
}
}
}

View File

@ -1,3 +0,0 @@
resource "dynatrace_audit_log" "test" {
enabled = false
}

View File

@ -1,7 +1,7 @@
terraform {
required_providers {
dynatrace = {
version = "1.31.0"
version = "1.33.0"
source = "dynatrace-oss/dynatrace"
}
aws = {
@ -13,4 +13,9 @@ terraform {
provider "aws" {
region = var.aws_region
}
}
provider "dynatrace" {
dt_env_url = var.dt_env_url
dt_api_token = var.dt_api_token
}

View File

@ -1,13 +1,3 @@
stack = "acdc"
stage = "prelive"
name = "dynatrace-prelive"
aws_region = "us-east-1"
tags = {
"Managed_By" : "NTT_team"
}
kms = {
"s3" = "arn:aws:kms:eu-west-1:248567303878:key/8d860956-4033-4782-ab30-6cb84b31964e"
}
dt_env_url = "https://console.prelive.eu.mon.vsds.swarm.audi/e/e7acd689-2169-4b83-aace-8c4e75c67446/api"

View File

@ -2,29 +2,10 @@ variable "aws_region" {
description = "The aws region to deploy in"
}
variable "name" {
description = "Name to be used on all the resources as identifier"
type = string
default = ""
variable "dt_env_url" {
description = "Dynatrace Environment URL"
}
variable "stack" {
description = "Environment stack"
default = "vsds"
variable "dt_api_token" {
description = "Dynatrace API Token"
}
variable "stage" {
description = "Environment stage"
}
variable "tags" {
description = "A map of tags to add to all resources"
type = map(string)
default = {}
}
variable "kms" {
description = "A map of kms keys to be used for any resources."
type = map(string)
default = {}
}