Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,19 @@ pre-commit hooks.

### os x

```
```bash
# newer modules, use latest tf (1.13.4+)
brew tap hashicorp/tap
brew install hashicorp/tap/terraform

# for working with older modules, use tf 1.5.7
brew install terraform

# install dev dependencies
brew install pre-commit
brew install terraform-docs

# setup pre-commit
pre-commit install
```

Expand Down
19 changes: 0 additions & 19 deletions terraform/base/tf_state_lock_gcp-taskcluster-imaging.tf

This file was deleted.

58 changes: 28 additions & 30 deletions terraform/create_state.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ fi

STATE_NAME=$1

if [ -a "${STATE_NAME}" ]; then
if [ -e "${STATE_NAME}" ]; then
echo "Error: A file or dir by that name already exists"
exit 1
fi

if [ -a "base/tf_state_lock_${STATE_NAME}.tf" ]; then
# TODO: eventually remove, we don't use this any longer
if [ -e "base/tf_state_lock_${STATE_NAME}.tf" ]; then
echo "Error: A tf state lock file of that name already exists"
exit 1
fi
Expand All @@ -44,7 +45,7 @@ terraform {
backend "s3" {
bucket = "relops-tf-states"
key = "${STATE_NAME}.tfstate"
dynamodb_table = "tf_state_lock_${STATE_NAME}"
use_lockfile = true
region = "us-west-2"
}
}
Expand All @@ -59,38 +60,35 @@ tag_production_state = "production"
tag_owner_email = "${USER}@mozilla.com"
EOF

echo "Generating base/tf_state_lock_${STATE_NAME}.tf"
cat <<EOF >"base/tf_state_lock_${STATE_NAME}.tf"
resource "aws_dynamodb_table" "tf_state_lock_${STATE_NAME}" {
name = "tf_state_lock_${STATE_NAME}"
hash_key = "LockID"
read_capacity = 20
write_capacity = 20

attribute {
name = "LockID"
type = "S"
}

tags = {
Name = "${STATE_NAME} Terraform State Lock Table"
Terraform = "true"
Repo_url = var.repo_url
Environment = "prod"
Owner = "relops@mozilla.com"
}
}
EOF
# aerickson: i don't think is required now (but keep around for a bit)
#
# echo "Generating base/tf_state_lock_${STATE_NAME}.tf"
# cat <<EOF >"base/tf_state_lock_${STATE_NAME}.tf"
# resource "aws_dynamodb_table" "tf_state_lock_${STATE_NAME}" {
# name = "tf_state_lock_${STATE_NAME}"
# hash_key = "LockID"
# read_capacity = 20
# write_capacity = 20

# attribute {
# name = "LockID"
# type = "S"
# }

# tags = {
# Name = "${STATE_NAME} Terraform State Lock Table"
# Terraform = "true"
# Repo_url = var.repo_url
# Environment = "prod"
# Owner = "relops@mozilla.com"
# }
# }
# EOF

echo "\
-------------------------------------------------------------------------------
Success! Please run the following:

## to create the state lock dyanmodb
cd base
# for the apply below, if there are any deletions, exit and mention in #specops
terraform apply

## initialize the environment for your new module
cd ../${STATE_NAME}
terraform init
Expand Down
4 changes: 4 additions & 0 deletions terraform/gcp-taskcluster-imaging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

https://console.cloud.google.com/compute/instances?orgonly=true&project=taskcluster-imaging&supportedpurview=organizationId

## tf version requirements

This module requires terraform 1.13.4+ to work with the s3 state locking.

## applying

```bash
Expand Down
2 changes: 1 addition & 1 deletion terraform/gcp-taskcluster-imaging/backend.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
backend "s3" {
bucket = "relops-tf-states"
key = "gcp-taskcluster-imaging.tfstate"
dynamodb_table = "tf_state_lock_gcp-taskcluster-imaging"
use_lockfile = true
region = "us-west-2"
}
}