VSDSCP-212 Initial Commit
commit
b882c46a57
|
|
@ -0,0 +1,9 @@
|
||||||
|
.terraform
|
||||||
|
.terraform.lock.hcl
|
||||||
|
*.tfstate
|
||||||
|
*.tfstate.backup
|
||||||
|
id_rsa
|
||||||
|
id_rsa.pub
|
||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
.iml
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
1.4.5
|
||||||
|
|
@ -0,0 +1,101 @@
|
||||||
|
String release = "${env.RELEASE_VERSION ?: "SNAPSHOT"}"
|
||||||
|
String tag = "modules-aws-$release"
|
||||||
|
|
||||||
|
def modules_paths = [
|
||||||
|
"eu/prelive",
|
||||||
|
]
|
||||||
|
|
||||||
|
def terraform_check(paths) {
|
||||||
|
paths.each { path ->
|
||||||
|
sh("terraform -chdir=${path} init -backend=false")
|
||||||
|
sh("terraform -chdir=${path} fmt -recursive --check")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pipeline {
|
||||||
|
agent {
|
||||||
|
node {
|
||||||
|
label 'vsds-terraform'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
GIT_SSH_COMMAND = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
||||||
|
}
|
||||||
|
|
||||||
|
options {
|
||||||
|
timestamps()
|
||||||
|
ansiColor('xterm')
|
||||||
|
disableConcurrentBuilds(abortPrevious: true)
|
||||||
|
timeout(time: 1, unit: 'HOURS')
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage("Check Tag") {
|
||||||
|
when { expression { !release.equals("SNAPSHOT") } }
|
||||||
|
steps {
|
||||||
|
sshagent(credentials: ['sofa-user-automation']) {
|
||||||
|
script {
|
||||||
|
env.PLAN_STATUS = sh(script: """
|
||||||
|
| if [[ "\$(git ls-remote origin 2>/dev/null | grep 'refs/tags/$tag\$')" ]]; then
|
||||||
|
| echo "Release $tag exists"
|
||||||
|
| exit 1
|
||||||
|
| fi
|
||||||
|
""".stripMargin('| '), returnStatus: true)
|
||||||
|
|
||||||
|
if (env.PLAN_STATUS == "1") {
|
||||||
|
currentBuild.result = "FAILURE"
|
||||||
|
error('Aborting the build.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Terraform validate') {
|
||||||
|
steps {
|
||||||
|
container('terraform') {
|
||||||
|
sshagent(credentials: ['sofa-user-automation']) {
|
||||||
|
script {
|
||||||
|
terraform_check(modules_paths)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Terraform plan') {
|
||||||
|
steps {
|
||||||
|
container('terraform') {
|
||||||
|
sshagent(credentials: ['sofa-user-automation']) {
|
||||||
|
sh 'terraform plan'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Create tag') {
|
||||||
|
when { expression { !release.equals("SNAPSHOT") } }
|
||||||
|
steps {
|
||||||
|
sshagent(credentials: ['sofa-user-automation']) {
|
||||||
|
sh """
|
||||||
|
| git tag $tag
|
||||||
|
| git push origin $tag
|
||||||
|
""".stripMargin('| ')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
cleanWs()
|
||||||
|
script {
|
||||||
|
currentBuild.result = currentBuild.result ?: 'SUCCESS'
|
||||||
|
notifyBitbucket(projectKey: 'modules')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
terraform {
|
||||||
|
backend "s3" {
|
||||||
|
bucket = "acdc-eu-west-1-prelive-tfstate"
|
||||||
|
key = "acdc/dynatrace/bootstrap.tfstate"
|
||||||
|
region = "eu-west-1"
|
||||||
|
encrypt = true
|
||||||
|
kms_key_id = "arn:aws:kms:eu-west-1:248567303878:key/8d860956-4033-4782-ab30-6cb84b31964e" #AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, kms-key
|
||||||
|
# dynamodb_table = "acdc-eu-west-1-prelive-tfstate-lock"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
module "s3-dynatrace" {
|
||||||
|
source = "git::ssh://git@collaboration.msi.audi.com:4444/vsdsinf/vsds-terraform-modules.git//modules/aws/marketplace/s3?ref=1.4.3"
|
||||||
|
|
||||||
|
name = format("%s-%s-%s-dynatrace", var.stack, var.aws_region, var.stage)
|
||||||
|
kms_key_arn = var.kms["s3"]
|
||||||
|
tags = merge(
|
||||||
|
var.tags,
|
||||||
|
{
|
||||||
|
Namespace = "platform"
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
dynatrace = {
|
||||||
|
version = "1.31.0"
|
||||||
|
source = "dynatrace-oss/dynatrace"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
# AUTO GENERATED, DON'T MODIFY
|
||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
# AUTO GENERATED, DON'T MODIFY
|
||||||
|
|
||||||
|
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 "stack" {
|
||||||
|
description = "Environment stack"
|
||||||
|
default = "vsds"
|
||||||
|
}
|
||||||
|
|
||||||
|
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 = {}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
String release = "${env.RELEASE_VERSION ?: "SNAPSHOT"}"
|
||||||
|
String tag = "modules-aws-$release"
|
||||||
|
|
||||||
|
def modules_paths = [
|
||||||
|
"modules/aws/dynatrace",
|
||||||
|
]
|
||||||
|
|
||||||
|
def terraform_check(paths) {
|
||||||
|
paths.each { path ->
|
||||||
|
sh("terraform -chdir=${path} init -backend=false")
|
||||||
|
sh("terraform -chdir=${path} fmt -recursive --check")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pipeline {
|
||||||
|
agent {
|
||||||
|
node {
|
||||||
|
label 'vsds-terraform'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
GIT_SSH_COMMAND = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
||||||
|
}
|
||||||
|
|
||||||
|
options {
|
||||||
|
timestamps()
|
||||||
|
ansiColor('xterm')
|
||||||
|
disableConcurrentBuilds(abortPrevious: true)
|
||||||
|
timeout(time: 1, unit: 'HOURS')
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage("Check Tag") {
|
||||||
|
when { expression { !release.equals("SNAPSHOT") } }
|
||||||
|
steps {
|
||||||
|
sshagent(credentials: ['sofa-user-automation']) {
|
||||||
|
script {
|
||||||
|
env.PLAN_STATUS = sh(script: """
|
||||||
|
| if [[ "\$(git ls-remote origin 2>/dev/null | grep 'refs/tags/$tag\$')" ]]; then
|
||||||
|
| echo "Release $tag exists"
|
||||||
|
| exit 1
|
||||||
|
| fi
|
||||||
|
""".stripMargin('| '), returnStatus: true)
|
||||||
|
|
||||||
|
if (env.PLAN_STATUS == "1") {
|
||||||
|
currentBuild.result = "FAILURE"
|
||||||
|
error('Aborting the build.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Terraform validate') {
|
||||||
|
steps {
|
||||||
|
container('terraform') {
|
||||||
|
sshagent(credentials: ['sofa-user-automation']) {
|
||||||
|
script {
|
||||||
|
terraform_check(modules_paths)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Create tag') {
|
||||||
|
when { expression { !release.equals("SNAPSHOT") } }
|
||||||
|
steps {
|
||||||
|
sshagent(credentials: ['sofa-user-automation']) {
|
||||||
|
sh """
|
||||||
|
| git tag $tag
|
||||||
|
| git push origin $tag
|
||||||
|
""".stripMargin('| ')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
cleanWs()
|
||||||
|
script {
|
||||||
|
currentBuild.result = currentBuild.result ?: 'SUCCESS'
|
||||||
|
notifyBitbucket(projectKey: 'modules')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
variable "name" {
|
||||||
|
description = "Name to be used on all the resources as identifier"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "stage" {
|
||||||
|
description = "Environment stage"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "region" {
|
||||||
|
type = string
|
||||||
|
description = "The aws region to deploy in"
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue