automated terminal push
This commit is contained in:
23
Jenkinsfile
vendored
23
Jenkinsfile
vendored
@@ -82,19 +82,22 @@ pipeline {
|
|||||||
echo "✅ Terraform backend created successfully"
|
echo "✅ Terraform backend created successfully"
|
||||||
} else {
|
} else {
|
||||||
echo "⚠️ Terraform apply failed, checking if resources already exist..."
|
echo "⚠️ Terraform apply failed, checking if resources already exist..."
|
||||||
def bucketCheck = sh(
|
def bucketExists = sh(
|
||||||
script: "aws s3api head-bucket --bucket ${TF_BACKEND_BUCKET} --region ${TF_VAR_aws_region} 2>/dev/null && echo 'exists' || echo 'missing'",
|
script: "aws s3api head-bucket --bucket ${TF_BACKEND_BUCKET} --region ${TF_VAR_aws_region} 2>/dev/null",
|
||||||
returnStdout: true
|
returnStatus: true
|
||||||
).trim()
|
) == 0
|
||||||
def tableCheck = sh(
|
def tableExists = sh(
|
||||||
script: "aws dynamodb describe-table --table-name ${TF_DDB_TABLE} --region ${TF_VAR_aws_region} 2>/dev/null && echo 'exists' || echo 'missing'",
|
script: "aws dynamodb describe-table --table-name ${TF_DDB_TABLE} --region ${TF_VAR_aws_region} 2>/dev/null",
|
||||||
returnStdout: true
|
returnStatus: true
|
||||||
).trim()
|
) == 0
|
||||||
|
|
||||||
if (bucketCheck == "exists" && tableCheck == "exists") {
|
if (bucketExists && tableExists) {
|
||||||
echo "✅ Terraform backend already exists - continuing..."
|
echo "✅ Terraform backend already exists - continuing..."
|
||||||
} else {
|
} else {
|
||||||
error("❌ Backend bootstrap failed and resources don't exist. Manual intervention required.")
|
echo "❌ Backend bootstrap failed and resources don't exist:"
|
||||||
|
echo " S3 Bucket exists: ${bucketExists}"
|
||||||
|
echo " DynamoDB Table exists: ${tableExists}"
|
||||||
|
error("Manual intervention required.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user