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
if ! env_list="$(terraform env list)"; then | |
exit 1 | |
fi | |
if [[ "${env_list}" == *"${ENV}_${REGION}"* ]]; then | |
terraform env select "${ENV}_${REGION}" | |
else | |
terraform env new "${ENV}_${REGION}" | |
fi |
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 "s3" { | |
bucket = "tfstate.foobar.local" | |
key = "FE/web-frontend" | |
region = "your-buckets-region" | |
} | |
} |
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
variable "env" { | |
type = "string" | |
} | |
variable "region" { | |
type = "string" | |
} | |
module "names" { | |
source = "./names" |
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
variable "env" { | |
type = "string" | |
} | |
variable "region" { | |
type = "string" | |
} | |
variable "endpoint_name" { | |
type = "string" |
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
TF_VAR_env=${ENV} TF_VAR_region=${REGION} \ | |
terraform apply |
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 remote config \ | |
-backend=s3 | |
-backend-config="bucket=tfstate.foobar.local" \ | |
-backend-config="key=FE/app-frontend/${ENV}/${REGION}/terraform.tfstate" |
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
#!/usr/bin/env bash | |
# Say you have a S3 state with KMS on, with the appropriate variables | |
# configured below (these could also be parameterized but I wanted to | |
# make this gist as easy as possible to digest). Using this script | |
# (or a reasonable facsimile thereof), you can emulate the old | |
# "terraform remote config" command that existed in TF pre-v0.9 | |
# by creating a file with your config in your Terraform directory. | |
# This file should be ignored in source control! |
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
package main | |
import ( | |
"bytes" | |
"fmt" | |
) | |
const in = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." | |
func wrap(old string, ll int) string { |
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
PW_RANGE = [*'0'..'9', *'A'..'Z', *'a'..'z'].freeze | |
password = Array.new(16) { PW_RANGE.sample }.join | |
puts password |
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
function decimalToIPv4(decIpAddr) { | |
ipBytes = []; | |
for (i=0;i<=3;i++) { | |
ipBytes.push((decIpAddr >> 8 * 3 - 8 * i) & 255); | |
} | |
return ipBytes.join("."); | |
} |