This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -s \ | |
--header "Authorization: Bearer $TOKEN" \ | |
https://app.terraform.io/api/v2/runs/{run-id} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "resource_group_name" { } | |
variable "location" { } | |
variable "account_names" { | |
type = list(string) | |
description = "List of names for storage accounts" | |
default = [ | |
"myaccount", | |
"hisaccount", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module "custom-igw" { | |
source = "app.terraform.io/<YOUR_TFC_ORG_NAME>/custom-igw/aws" | |
vpc_id = aws_vpc.primary-vpc.id | |
tags = var.tags | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getWorkspaceId() { | |
def response = httpRequest( | |
customHeaders: [ | |
[ name: "Authorization", value: "Bearer " + env.BEARER_TOKEN ], | |
[ name: "Content-Type", value: "application/vnd.api+json" ] | |
], | |
url: "https://app.terraform.io/api/v2/organizations/" + env.TF_ORGNAME + "/workspaces/" + env.TF_WORKSPACE | |
) | |
def data = new JsonSlurper().parseText(response.content) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"data": { | |
"attributes": { | |
"is-destroy":false, | |
"message": "Triggered run from Jenkins" | |
}, | |
"type":"runs", | |
"relationships": { | |
"workspace": { | |
"data": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def startPlan() { | |
def payload = buildPayload() | |
def response = httpRequest( | |
customHeaders: [ | |
[ name: "Authorization", value: "Bearer " + env.BEARER_TOKEN ], | |
[ name: "Content-Type", value: "application/vnd.api+json" ] | |
], | |
httpMode: 'POST', | |
requestBody: "${payload}", | |
url: "https://app.terraform.io/api/v2/runs" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getPlanStatus(runid) { | |
def result = "" | |
def response = httpRequest( | |
customHeaders: [[ name: "Authorization", value: "Bearer " + env.BEARER_TOKEN ]], | |
url: "https://app.terraform.io/api/v2/runs/${runid}" | |
) | |
def data = new JsonSlurper().parseText(response.content) | |
switch (data.data.attributes.status) { | |
case 'pending': | |
result = "noop" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def overridePolicy(policyid) { | |
def response = httpRequest( | |
customHeaders: [ | |
[ name: "Authorization", value: "Bearer " + env.BEARER_TOKEN ], | |
[ name: "Content-Type", value: "application/vnd.api+json" ] | |
], | |
httpMode: 'POST', | |
url: "https://app.terraform.io/api/v2/policy-checks/${policyid}/actions/override" | |
) | |
def data = new JsonSlurper().parseText(response.content) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def applyRun(runid) { | |
def response = httpRequest( | |
customHeaders: [ | |
[ name: "Authorization", value: "Bearer " + env.BEARER_TOKEN ], | |
[ name: "Content-Type", value: "application/vnd.api+json" ] | |
], | |
httpMode: 'POST', | |
responseBody: '{ comment: "Apply confirmed" }', | |
url: "https://app.terraform.io/api/v2/runs/${runid}/actions/apply" | |
) |