-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c8df34
commit acad849
Showing
11 changed files
with
283 additions
and
86 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.envrc | ||
.terraform/ | ||
bin/ | ||
tmp/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.envrc | ||
.terraform/ | ||
bin/ | ||
tmp/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
ARG TERRAFORM_VERSION=latest | ||
FROM hashicorp/terraform:$TERRAFORM_VERSION AS terraform | ||
|
||
FROM golang:1.17.6-alpine3.15 | ||
RUN apk --no-cache add make git bash curl | ||
|
||
# Install terraform | ||
COPY --from=terraform /bin/terraform /usr/local/bin/ | ||
|
||
# Install tfupdate | ||
ENV TFUPDATE_VERSION 0.6.5 | ||
RUN curl -fsSL https://github.com/minamijoyo/tfupdate/releases/download/v${TFUPDATE_VERSION}/tfupdate_${TFUPDATE_VERSION}_linux_amd64.tar.gz \ | ||
| tar -xzC /usr/local/bin && chmod +x /usr/local/bin/tfupdate | ||
|
||
# Install tfmigrate | ||
ENV TFMIGRATE_VERSION 0.3.2 | ||
RUN curl -fsSL https://github.com/minamijoyo/tfmigrate/releases/download/v${TFMIGRATE_VERSION}/tfmigrate_${TFMIGRATE_VERSION}_linux_amd64.tar.gz \ | ||
| tar -xzC /usr/local/bin && chmod +x /usr/local/bin/tfmigrate | ||
|
||
WORKDIR /work | ||
|
||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
COPY . . | ||
RUN make install | ||
|
||
ENTRYPOINT ["./entrypoint.sh"] |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
version: '3' | ||
services: | ||
tfedit: | ||
build: | ||
context: . | ||
args: | ||
TERRAFORM_VERSION: ${TERRAFORM_VERSION:-latest} | ||
volumes: | ||
- ".:/work" | ||
environment: | ||
CGO_ENABLED: 0 # disable cgo for go test | ||
LOCALSTACK_ENDPOINT: "http://localstack:4566" | ||
# Use the same filesystem to avoid a checksum mismatch error | ||
# or a file busy error caused by asynchronous IO. | ||
TF_PLUGIN_CACHE_DIR: "/tmp/plugin-cache" | ||
depends_on: | ||
- localstack | ||
|
||
localstack: | ||
image: localstack/localstack:0.14.2 | ||
ports: | ||
- "4566:4566" | ||
environment: | ||
DEBUG: "true" | ||
SERVICES: "s3" | ||
DEFAULT_REGION: "ap-northeast-1" | ||
# This s3 bucket is used for only remote state storage for testing | ||
# and is not a target for upgrade. | ||
S3_BUCKET: "tfstate-test" | ||
volumes: | ||
- "./scripts/localstack:/docker-entrypoint-initaws.d" # initialize scripts on startup | ||
|
||
dockerize: | ||
image: jwilder/dockerize | ||
depends_on: | ||
- localstack |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Create a plugin cache directory in advance. | ||
# The terraform command doesn't create it automatically. | ||
if [ -n "${TF_PLUGIN_CACHE_DIR}" ]; then | ||
mkdir -p "${TF_PLUGIN_CACHE_DIR}" | ||
fi | ||
|
||
exec "$@" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
awslocal s3 mb s3://"$S3_BUCKET" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
awslocal s3api wait bucket-exists --bucket "$S3_BUCKET" |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
terraform { | ||
# https://www.terraform.io/docs/backends/types/s3.html | ||
backend "s3" { | ||
region = "ap-northeast-1" | ||
bucket = "tfstate-test" | ||
key = "test/terraform.tfstate" | ||
|
||
// mock s3 endpoint with localstack | ||
endpoint = "http://localstack:4566" | ||
access_key = "dummy" | ||
secret_key = "dummy" | ||
skip_credentials_validation = true | ||
skip_metadata_api_check = true | ||
force_path_style = true | ||
} | ||
|
||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "3.74.3" | ||
} | ||
} | ||
} | ||
|
||
# https://www.terraform.io/docs/providers/aws/index.html | ||
# https://www.terraform.io/docs/providers/aws/guides/custom-service-endpoints.html#localstack | ||
provider "aws" { | ||
region = "ap-northeast-1" | ||
|
||
access_key = "dummy" | ||
secret_key = "dummy" | ||
skip_credentials_validation = true | ||
skip_metadata_api_check = true | ||
skip_region_validation = true | ||
skip_requesting_account_id = true | ||
s3_force_path_style = true | ||
|
||
// mock endpoints with localstack | ||
endpoints { | ||
s3 = "http://localstack:4566" | ||
} | ||
} |
Oops, something went wrong.