This file contains 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
terraform { | |
backend "remote" { | |
organization = "org" | |
hostname = "hostname" | |
workspaces { | |
name = "hcl" | |
} | |
} |
This file contains 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
import { Construct } from "constructs"; | |
import { App, RemoteBackend, TerraformStack, TerraformHclModule, TerraformOutput } from "cdktf"; | |
import { AwsProvider } from "@cdktf/provider-aws"; | |
// These variables are hardcoded here for brevity but the values could be stored and fetched from anywhere. | |
const DEPLOYMENT_TARGETS = { | |
// region : aws account id | |
"ap-northeast-1": "582318560864", | |
"ap-northeast-2": "600734575887", | |
"ap-south-1": "718504428378", |
This file contains 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
# These variables are declared as locals here for brevity but could equally be terraform variables, a terraform http data source, output from another module etc. | |
locals { | |
deployment_targets = { | |
# region = aws account id | |
"eu-west-1" = "00000000000" | |
"eu-west-2" = "11111111111" | |
} | |
module_version = "1.2.3" | |
} |
This file contains 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
#!/bin/bash | |
set -eo pipefail | |
# Scalr pre-init hook script to install nodejs lts in and synthesise the cdktf into terraform json. | |
# TODO: support custom runners on other ARCHs | |
ARCH="x64" | |
if test -f "cdk.tf.json"; then | |
echo "cdk.tf.json already exists, no re-synthing." | |
exit 0 |
This file contains 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
#!/bin/bash | |
# This script was used to migrate Terraform workspace state from Hashicorp Terraform Cloud (TFC) to Scalr. | |
# It loops through all projects in a given directory, extracts the workspace id, downloads the state from TFC, and then uploads it to Scalr. | |
# It was made for the Ably Terraform projects directory structure and so will unlikely work as-is. It can easily be tweaked to support other folder structures. | |
# The workspaces in Scalr need to already exist. | |
set -e | |
set -o pipefail |