Skip to content

Commit 7590bf3

Browse files
authored
Merge pull request #3 from rhythmictech/readme
Add readme and commit hooks
2 parents 0e0687f + 071cd17 commit 7590bf3

File tree

15 files changed

+252
-10
lines changed

15 files changed

+252
-10
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: pre-commit-check
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- develop
8+
pull_request:
9+
10+
jobs:
11+
build:
12+
runs-on: macOS-latest
13+
steps:
14+
- uses: actions/checkout@v1
15+
- name: Install prerequisites
16+
run: ./bin/install-macos.sh
17+
- name: initiallize Terraform
18+
run: terraform init --backend=false
19+
- uses: actions/cache@v1
20+
with:
21+
path: ~/.cache/pre-commit
22+
key: pre-commit|${{ hashFiles('.pre-commit-config.yaml') }}
23+
restore-keys: |
24+
pre-commit
25+
- name: pre-commit run all
26+
run: |
27+
pre-commit run -a
28+
env:
29+
AWS_DEFAULT_REGION: us-east-1
30+
SKIP: terraform_tflint_deep

.pre-commit-config.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
repos:
2+
- repo: https://github.com/antonbabenko/pre-commit-terraform
3+
rev: v1.31.0
4+
hooks:
5+
- id: terraform_docs
6+
args:
7+
- --args=--sort-by-required
8+
- id: terraform_fmt
9+
- id: terraform_tflint
10+
alias: terraform_tflint_deep
11+
name: terraform_tflint_deep
12+
args:
13+
- --args=--deep
14+
- id: terraform_tflint
15+
alias: terraform_tflint_nocreds
16+
name: terraform_tflint_nocreds
17+
- id: terraform_tfsec
18+
- id: terraform_validate
19+
exclude: examples
20+
- repo: https://github.com/pre-commit/pre-commit-hooks
21+
rev: v3.0.0
22+
hooks:
23+
- id: check-case-conflict
24+
- id: check-json
25+
- id: check-merge-conflict
26+
- id: check-symlinks
27+
- id: check-yaml
28+
args:
29+
- --unsafe
30+
- id: end-of-file-fixer
31+
- id: trailing-whitespace
32+
- id: mixed-line-ending
33+
args:
34+
- --fix=lf
35+
- id: no-commit-to-branch
36+
- id: pretty-format-json
37+
args:
38+
- --autofix
39+
- --top-keys=name,Name
40+
- id: trailing-whitespace
41+
args:
42+
- --markdown-linebreak-ext=md
43+
exclude: README.md

.tflint.hcl

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
config {
2+
module = true
3+
deep_check = false
4+
}
5+
6+
rule "terraform_deprecated_interpolation" {
7+
enabled = true
8+
}
9+
10+
rule "terraform_unused_declarations" {
11+
enabled = true
12+
}
13+
14+
rule "terraform_comment_syntax" {
15+
enabled = true
16+
}
17+
18+
rule "terraform_documented_outputs" {
19+
enabled = true
20+
}
21+
22+
rule "terraform_documented_variables" {
23+
enabled = true
24+
}
25+
26+
rule "terraform_typed_variables" {
27+
enabled = true
28+
}
29+
30+
rule "terraform_module_pinned_source" {
31+
enabled = true
32+
}
33+
34+
rule "terraform_naming_convention" {
35+
enabled = true
36+
format = "snake_case"
37+
}
38+
39+
rule "terraform_required_version" {
40+
enabled = true
41+
}
42+
43+
rule "terraform_required_providers" {
44+
enabled = true
45+
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Rhythmic Technologies, Inc.
3+
Copyright (c) 2020 Rhythmic Technologies, Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# terraform-aws-imagebuilder-pipeline [![](https://github.com/rhythmictech/terraform-aws-imagebuilder-pipeline/workflows/pre-commit-check/badge.svg)](https://github.com/rhythmictech/terraform-aws-imagebuilder-pipeline/actions) <a href="https://twitter.com/intent/follow?screen_name=RhythmicTech"><img src="https://img.shields.io/twitter/follow/RhythmicTech?style=social&logo=RhythmicTech" alt="follow on Twitter"></a>
2+
Terraform module for creating EC2 Image Builder Pipelines from Cloudformation
3+
4+
## Example
5+
Here's what using the module will look like
6+
```hcl
7+
module "test_pipeline" {
8+
source = "rhythmictech/imagebuilder-recipe/aws"
9+
version = "~> 0.2.0"
10+
11+
description = "Testing pipeline"
12+
name = "test-pipeline"
13+
tags = local.tags
14+
recipe_arn = module.test_recipe.recipe_arn
15+
public = false
16+
}
17+
```
18+
19+
## About
20+
Allows the creation of EC2 Image Builder Pipelines with Cloudformation until native support is added to TF
21+
22+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
23+
## Requirements
24+
25+
| Name | Version |
26+
|------|---------|
27+
| terraform | >= 0.12.2 |
28+
| aws | ~> 2.44 |
29+
30+
## Providers
31+
32+
| Name | Version |
33+
|------|---------|
34+
| aws | ~> 2.44 |
35+
36+
## Inputs
37+
38+
| Name | Description | Type | Default | Required |
39+
|------|-------------|------|---------|:--------:|
40+
| name | name to use for component | `string` | n/a | yes |
41+
| recipe\_arn | ARN of the recipe to use. Must change with Recipe version | `string` | n/a | yes |
42+
| additional\_iam\_policy\_arns | List of ARN policies for addional builder permissions | `list(string)` | `[]` | no |
43+
| cloudformation\_timeout | How long to wait (in minutes) for CFN to apply before giving up | `number` | `10` | no |
44+
| description | description of component | `string` | `null` | no |
45+
| enabled | Whether pipeline is ENABLED or DISABLED | `bool` | `true` | no |
46+
| instance\_types | Instance types to create images from. It's unclear why this is a list. Possibly because different types can result in different images (like ARM instances) | `list(string)` | <pre>[<br> "t3.medium"<br>]</pre> | no |
47+
| key\_pair | EC2 key pair to add to the default user on the builder | `string` | `null` | no |
48+
| license\_config\_arns | If you're using License Manager, your ARNs go here | `list(string)` | `null` | no |
49+
| log\_bucket | Bucket to store logs in. If this is ommited logs will not be stored | `string` | `null` | no |
50+
| log\_prefix | S3 prefix to store logs at. Recommended if sharing bucket with other pipelines | `string` | `null` | no |
51+
| public | Whether resulting AMI should be public | `bool` | `false` | no |
52+
| regions | Regions that AMIs will be available in | `list(string)` | <pre>[<br> "us-east-1",<br> "us-east-2",<br> "us-west-1",<br> "us-west-2",<br> "ca-central-1"<br>]</pre> | no |
53+
| schedule | Schedule expression for when pipeline should run automatically https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-imagebuilder-imagepipeline-schedule.html | <pre>object({<br> PipelineExecutionStartCondition = string<br> ScheduleExpression = string<br> })</pre> | <pre>{<br> "PipelineExecutionStartCondition": "EXPRESSION_MATCH_AND_DEPENDENCY_UPDATES_AVAILABLE",<br> "ScheduleExpression": "cron(0 0 * * mon)"<br>}</pre> | no |
54+
| security\_group\_ids | Security group IDs for the Image Builder | `list(string)` | `null` | no |
55+
| shared\_account\_ids | AWS accounts to share AMIs with. If this is left null AMIs will be public | `list(string)` | `[]` | no |
56+
| sns\_topic\_arn | SNS topic to notify when new images are created | `string` | `null` | no |
57+
| subnet | Subnet ID to use for builder | `string` | `null` | no |
58+
| tags | map of tags to use for CFN stack and component | `map(string)` | `{}` | no |
59+
| terminate\_on\_failure | Change to false if you want to ssh into a builder for debugging after failure | `bool` | `true` | no |
60+
| test\_config | Whether to run tests during image creation and maximum time to allow tests to run | <pre>object({<br> ImageTestsEnabled = bool<br> TimeoutMinutes = number<br> })</pre> | <pre>{<br> "ImageTestsEnabled": true,<br> "TimeoutMinutes": 60<br>}</pre> | no |
61+
62+
## Outputs
63+
64+
| Name | Description |
65+
|------|-------------|
66+
| pipeline\_arn | ARN of EC2 Image Builder Pipeline |
67+
68+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
69+
70+
## The Giants underneath this module
71+
- pre-commit.com/
72+
- terraform.io/
73+
- github.com/tfutils/tfenv
74+
- github.com/segmentio/terraform-docs

bin/install-macos.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
echo 'installing brew packages'
4+
brew update
5+
brew tap liamg/tfsec
6+
brew install tfenv tflint terraform-docs pre-commit liamg/tfsec/tfsec coreutils
7+
brew upgrade tfenv tflint terraform-docs pre-commit liamg/tfsec/tfsec coreutils
8+
9+
echo 'installing pre-commit hooks'
10+
pre-commit install
11+
12+
echo 'setting pre-commit hooks to auto-install on clone in the future'
13+
git config --global init.templateDir ~/.git-template
14+
pre-commit init-templatedir ~/.git-template
15+
16+
echo 'installing terraform with tfenv'
17+
tfenv install min-required
18+
tfenv use min-required

cloudformation.yml.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Resources:
3333
${ indent(8, chomp(yamlencode(tags))) }
3434
infraConfig:
3535
Type: AWS::ImageBuilder::InfrastructureConfiguration
36-
Properties:
36+
Properties:
3737
Name: ${name}-infrastructure-configuration
3838
%{~ if description != null ~}
3939
Description: ${description}

example/basic/global.auto.tfvars

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/basic/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# basic example
2+
A basic example for this repository
3+
4+
## Code
5+
```hcl
6+
module "test_pipeline" {
7+
source = "rhythmictech/imagebuilder-recipe/aws"
8+
version = "~> 0.2.0"
9+
10+
description = "Testing pipeline"
11+
name = "test-pipeline"
12+
tags = local.tags
13+
recipe_arn = module.test_recipe.recipe_arn
14+
public = false
15+
}
16+
```
17+
18+
## Applying
19+
```
20+
> terraform apply
21+
22+
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
23+
24+
Outputs:
25+
26+
pipeline_arn = arn:aws:imagebuilder:us-east-1:000000000000:image-pipeline/test-pipeline
27+
```
File renamed without changes.

0 commit comments

Comments
 (0)