Skip to content

Commit 79ba11e

Browse files
committed
Initial commit
0 parents  commit 79ba11e

File tree

10 files changed

+162
-0
lines changed

10 files changed

+162
-0
lines changed

.github/workflows/check.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Check
2+
on: [ push, pull_request ]
3+
4+
jobs:
5+
validate:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v2
9+
10+
- uses: hashicorp/setup-terraform@v1
11+
with:
12+
terraform_version: 0.14.0
13+
14+
- name: Validate Module
15+
env:
16+
AWS_REGION: 'eu-west-1'
17+
run: |
18+
terraform init -backend=false
19+
terraform validate
20+
terraform fmt -check
21+
- name: Validate Examples
22+
env:
23+
AWS_REGION: 'eu-west-1'
24+
run: |
25+
for example in $(find examples -maxdepth 1 -mindepth 1 -type d); do
26+
cd $example
27+
terraform init -backend=false
28+
terraform validate
29+
terraform fmt -check
30+
cd -
31+
done

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.tfvars
2+
*.tfstate*
3+
*.lock.hcl*
4+
.terraform/

.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
repos:
2+
- repo: git://github.com/pre-commit/pre-commit-hooks
3+
rev: v3.4.0
4+
hooks:
5+
- id: check-json
6+
- id: check-merge-conflict
7+
- id: check-yaml
8+
- id: detect-private-key
9+
- id: pretty-format-json
10+
args:
11+
- --autofix
12+
- id: trailing-whitespace
13+
14+
- repo: git://github.com/igorshubovych/markdownlint-cli
15+
rev: v0.26.0
16+
hooks:
17+
- id: markdownlint
18+
19+
- repo: git://github.com/antonbabenko/pre-commit-terraform
20+
rev: v1.45.0
21+
hooks:
22+
- id: terraform_docs
23+
- id: terraform_fmt

LICENSE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Licensed under the Apache License, Version 2.0 (the "License");
2+
you may not use this file except in compliance with the License.
3+
You may obtain a copy of the License at
4+
5+
http://www.apache.org/licenses/LICENSE-2.0
6+
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# AWS S3 Bootstrap State Module
2+
3+
A Terraform module to create and manage Terraform state on AWS.
4+
Available through the [Terraform registry](https://registry.terraform.io/modules/eriktisme/bootstrap/aws/latest).
5+
6+
## Terraform versions
7+
8+
Terraform 0.13 and above are supported.
9+
10+
## Usage example
11+
12+
- A simple example is contained in the [examples directory](./examples/simple).
13+
14+
## Authors
15+
16+
- [Erik van Dam](https://github.com/eriktisme)
17+
18+
## License
19+
20+
The Apache License, Version 2.0. Please see [License File](LICENSE) for more information.

examples/simple/main.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module "bootstrap" {
2+
source = "../../"
3+
4+
project_alias = "simple"
5+
region = "eu-west-1"
6+
}

main.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module "terraform_state_bucket" {
2+
source = "eriktisme/s3-bucket/aws"
3+
version = "0.1.0"
4+
5+
bucket = "${var.project_alias}-${var.bucket_purpose}-${var.region}"
6+
7+
tags = merge(var.tags)
8+
}
9+
10+
resource "aws_dynamodb_table" "terraform_state_lock" {
11+
hash_key = "LockID"
12+
name = var.table_name
13+
read_capacity = 2
14+
write_capacity = 2
15+
16+
server_side_encryption {
17+
enabled = true
18+
}
19+
20+
attribute {
21+
name = "LockID"
22+
type = "S"
23+
}
24+
25+
tags = merge(var.tags)
26+
}

outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "dynamodb_table" {
2+
description = "The name of the DynamoDB table created for the Terraform state."
3+
value = aws_dynamodb_table.terraform_state_lock.id
4+
}

variables.tf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
variable "table_name" {
2+
description = "The table name for the Terraform state lock."
3+
default = "terraform-state-lock"
4+
type = string
5+
}
6+
7+
variable "project_alias" {
8+
description = "The AWS account alias."
9+
type = string
10+
}
11+
12+
variable "bucket_purpose" {
13+
description = "The identification of the bucket's purpose."
14+
default = "terraform-state"
15+
type = string
16+
}
17+
18+
variable "region" {
19+
description = "The AWS region the account will be bootstrapped in."
20+
type = string
21+
}
22+
23+
variable "tags" {
24+
description = "A mapping of tags to assign to the table."
25+
type = map(string)
26+
default = {}
27+
}

versions.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 0.13"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = "~> 3.23.0"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)