Skip to content

Commit dc1b44f

Browse files
author
Your Name
committed
Merge: Simplify pipeline to use S3 sources and add pip configuration support
2 parents d5cae86 + f5eb93a commit dc1b44f

File tree

14 files changed

+231
-292
lines changed

14 files changed

+231
-292
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
2+
# This is a basic workflow to help you get started with Actions
3+
4+
name: Terraform Plan
5+
6+
7+
# Controls when the workflow will run
8+
on:
9+
pull_request:
10+
11+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
12+
jobs:
13+
# This workflow contains a single job called "build"
14+
build:
15+
# The type of runner that the job will run on
16+
runs-on: [ ubuntu-latest ]
17+
env:
18+
AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
19+
AWS_ACCESS_KEY_ID: "${{ vars.AWS_ACCESS_KEY_ID }}"
20+
AWS_SESSION_TOKEN: "${{ secrets.AWS_SESSION_TOKEN }}"
21+
22+
23+
# Steps represent a sequence of tasks that will be executed as part of the job
24+
steps:
25+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
26+
- uses: actions/checkout@v3
27+
with:
28+
ref: ${{ github.head_ref }}
29+
token: ${{ secrets.GH_TOKEN }}
30+
31+
- uses: actions/setup-node@v4
32+
with:
33+
node-version: 16
34+
35+
- uses: hashicorp/setup-terraform@v3.1.2
36+
with:
37+
terraform_version: ${{ vars.terraform_version }}
38+
39+
- name: Terraform Format
40+
id: fmt
41+
run: |
42+
terraform fmt
43+
if ! git diff-index --quiet HEAD; then
44+
git config --global user.name 'arnol377'
45+
git config --global user.email 'david.j.arnold.jr@census.gov'
46+
git commit -am "Autoformatting TF Code"
47+
git push
48+
echo "auto_format=true" >> $GITHUB_ENV
49+
fi
50+
51+
- name: Autoformat Halt
52+
if: env.auto_format == 'true'
53+
run: exit 0
54+
55+
- name: Terraform Init
56+
id: init
57+
run: terraform init -upgrade
58+
59+
- name: Terraform Validate
60+
id: validate
61+
run: terraform validate
62+
63+
- name: Update Pull Request
64+
uses: actions/github-script@v6
65+
if: github.event_name == 'pull_request'
66+
with:
67+
github-token: ${{ secrets.GH_TOKEN }}
68+
script: |
69+
const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
70+
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
71+
#### Terraform Validation 🤖\`${{ steps.validate.outcome }}\`
72+
#### Terraform Plan:
73+
${{ steps.plan.outcome }}
74+
*Pushed by: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`;
75+
76+
github.rest.issues.createComment({
77+
issue_number: context.issue.number,
78+
owner: context.repo.owner,
79+
repo: context.repo.repo,
80+
body: output
81+
})

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ override.tf.json
3535
# Ignore CLI configuration files
3636
.terraformrc
3737
terraform.rc
38+
.tflog

.terraform.lock.hcl

Lines changed: 30 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ HappyPathway
151151

152152
| Name | Version |
153153
|------|---------|
154-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.86.0 |
155-
| <a name="provider_random"></a> [random](#provider\_random) | 3.6.3 |
154+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.91.0 |
155+
| <a name="provider_random"></a> [random](#provider\_random) | 3.7.1 |
156156
| <a name="provider_tls"></a> [tls](#provider\_tls) | 4.0.6 |
157157

158158
## Modules
@@ -170,6 +170,9 @@ HappyPathway
170170

171171
| Name | Type |
172172
|------|------|
173+
| [aws_iam_instance_profile.build_user_instance_profile](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_instance_profile) | resource |
174+
| [aws_iam_role.build_user_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
175+
| [aws_iam_role_policy.build_user_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource |
173176
| [aws_key_pair.deployer](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/key_pair) | resource |
174177
| [aws_secretsmanager_secret.secrets](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret) | resource |
175178
| [aws_secretsmanager_secret.ssh_key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret) | resource |
@@ -193,9 +196,7 @@ HappyPathway
193196
| Name | Description | Type | Default | Required |
194197
|------|-------------|------|---------|:--------:|
195198
| <a name="input_ami"></a> [ami](#input\_ami) | n/a | <pre>object({<br> instance_type = string<br> source_ami = string<br> })</pre> | `null` | no |
196-
| <a name="input_ansible_bucket"></a> [ansible\_bucket](#input\_ansible\_bucket) | Ansible bucket details | <pre>object({<br> name = string,<br> key = string<br> })</pre> | `null` | no |
197-
| <a name="input_ansible_repo"></a> [ansible\_repo](#input\_ansible\_repo) | Source of Ansible Repo | <pre>object({<br> arn = optional(string)<br> repository_name = optional(string, "image-pipeline-ansible-playbooks")<br> branch = optional(string, "main")<br> })</pre> | `null` | no |
198-
| <a name="input_ansible_source_type"></a> [ansible\_source\_type](#input\_ansible\_source\_type) | Type of source to be used for the Ansible CodePipeline | `string` | `"CodeCommit"` | no |
199+
| <a name="input_ansible_bucket"></a> [ansible\_bucket](#input\_ansible\_bucket) | Ansible bucket details | <pre>object({<br> name = string,<br> key = string,<br> arn = string<br> })</pre> | `null` | no |
199200
| <a name="input_assets_bucket_name"></a> [assets\_bucket\_name](#input\_assets\_bucket\_name) | Name of the S3 bucket used to store the deployment artifacts | `string` | `"image-pipeline-assets"` | no |
200201
| <a name="input_build_environment_variables"></a> [build\_environment\_variables](#input\_build\_environment\_variables) | n/a | <pre>list(object({<br> name = string<br> value = string<br> type = optional(string, "PLAINTEXT")<br> }))</pre> | `null` | no |
201202
| <a name="input_build_project_source"></a> [build\_project\_source](#input\_build\_project\_source) | Source Code Repo for Playbook | `string` | `"CODEPIPELINE"` | no |
@@ -207,24 +208,23 @@ HappyPathway
207208
| <a name="input_builder_images"></a> [builder\_images](#input\_builder\_images) | n/a | `map(string)` | `{}` | no |
208209
| <a name="input_builder_type"></a> [builder\_type](#input\_builder\_type) | Type of codebuild run environment | `string` | `"LINUX_CONTAINER"` | no |
209210
| <a name="input_codepipeline_iam_role_name"></a> [codepipeline\_iam\_role\_name](#input\_codepipeline\_iam\_role\_name) | Name of the IAM role to be used by the Codepipeline | `string` | `"codepipeline-role"` | no |
211+
| <a name="input_create_build_user"></a> [create\_build\_user](#input\_create\_build\_user) | Whether to create a build user. Set to false if you want to use an existing user. | `bool` | `true` | no |
210212
| <a name="input_create_new_role"></a> [create\_new\_role](#input\_create\_new\_role) | Whether to create a new IAM Role. Values are true or false. Defaulted to true always. | `bool` | `true` | no |
211213
| <a name="input_docker_build"></a> [docker\_build](#input\_docker\_build) | n/a | `bool` | `false` | no |
212214
| <a name="input_extra_parameters"></a> [extra\_parameters](#input\_extra\_parameters) | n/a | `map(string)` | `{}` | no |
213215
| <a name="input_goss_binary"></a> [goss\_binary](#input\_goss\_binary) | GOSS Profile to be used for testing | `string` | `"goss-linux-amd64"` | no |
214-
| <a name="input_goss_bucket"></a> [goss\_bucket](#input\_goss\_bucket) | Goss bucket details | <pre>object({<br> name = string,<br> key = string<br> })</pre> | `null` | no |
216+
| <a name="input_goss_bucket"></a> [goss\_bucket](#input\_goss\_bucket) | Goss bucket details | <pre>object({<br> name = string,<br> key = string,<br> })</pre> | `null` | no |
215217
| <a name="input_goss_profile"></a> [goss\_profile](#input\_goss\_profile) | GOSS Profile to be used for testing | `string` | `"goss"` | no |
216-
| <a name="input_goss_repo"></a> [goss\_repo](#input\_goss\_repo) | Source of Goss Repo | <pre>object({<br> arn = optional(string)<br> repository_name = optional(string, "image-pipeline-goss-testing")<br> branch = optional(string, "main")<br> })</pre> | `null` | no |
217-
| <a name="input_goss_source_type"></a> [goss\_source\_type](#input\_goss\_source\_type) | Type of source to be used for the Goss CodePipeline | `string` | `"CodeCommit"` | no |
218218
| <a name="input_image"></a> [image](#input\_image) | n/a | <pre>object({<br> dest_tag = string<br> dest_docker_repo = string<br> source_image = string<br> source_tag = string<br> source_docker_repo = string<br> })</pre> | `null` | no |
219219
| <a name="input_image_volume_mapping"></a> [image\_volume\_mapping](#input\_image\_volume\_mapping) | n/a | <pre>list(object({<br> device_name = string<br> volume_size = number<br> volume_type = string<br> delete_on_termination = bool<br> encrypted = optional(bool, false)<br> iops = optional(number, null)<br> snapshot_id = optional(string, null)<br> throughput = optional(number, null)<br> virtual_name = optional(string, null)<br> kms_key_id = optional(string, null)<br> mount_path = optional(string, null)<br> }))</pre> | `[]` | no |
220+
| <a name="input_instance_profile"></a> [instance\_profile](#input\_instance\_profile) | n/a | `string` | `null` | no |
220221
| <a name="input_kms_key_id"></a> [kms\_key\_id](#input\_kms\_key\_id) | n/a | `string` | `null` | no |
221222
| <a name="input_nonmanaged_parameters"></a> [nonmanaged\_parameters](#input\_nonmanaged\_parameters) | n/a | `list(string)` | <pre>[<br> "dest_tag"<br>]</pre> | no |
222-
| <a name="input_packer_bucket"></a> [packer\_bucket](#input\_packer\_bucket) | Source bucket details | <pre>object({<br> name = string,<br> key = string<br> })</pre> | `null` | no |
223+
| <a name="input_packer_bucket"></a> [packer\_bucket](#input\_packer\_bucket) | Source bucket details | <pre>object({<br> name = string,<br> arn = string,<br> key = string<br> })</pre> | `null` | no |
223224
| <a name="input_packer_config"></a> [packer\_config](#input\_packer\_config) | Name of Packer Config in Repo | `string` | `"build.pkr.hcl"` | no |
224-
| <a name="input_packer_repo"></a> [packer\_repo](#input\_packer\_repo) | Source of the Terraform Repo | <pre>object({<br> arn = optional(string)<br> repository_name = optional(string, "linux-image-pipeline")<br> branch = optional(string, "main")<br> })</pre> | `null` | no |
225-
| <a name="input_packer_source_type"></a> [packer\_source\_type](#input\_packer\_source\_type) | Type of source to be used for the CodePipeline | `string` | `"CodeCommit"` | no |
226225
| <a name="input_packer_version"></a> [packer\_version](#input\_packer\_version) | Terraform CLI Version | `string` | `"1.10.3"` | no |
227226
| <a name="input_parameter_arns"></a> [parameter\_arns](#input\_parameter\_arns) | n/a | `list(string)` | `null` | no |
227+
| <a name="input_pip_bucket"></a> [pip\_bucket](#input\_pip\_bucket) | Pip bucket details | <pre>object({<br> name = string,<br> key = string,<br> })</pre> | `null` | no |
228228
| <a name="input_playbook"></a> [playbook](#input\_playbook) | n/a | `string` | `null` | no |
229229
| <a name="input_project_name"></a> [project\_name](#input\_project\_name) | Unique name for this project | `string` | n/a | yes |
230230
| <a name="input_required_packages"></a> [required\_packages](#input\_required\_packages) | n/a | <pre>list(object({<br> src = string<br> dest = string<br> }))</pre> | `[]` | no |
@@ -233,7 +233,6 @@ HappyPathway
233233
| <a name="input_shared_accounts"></a> [shared\_accounts](#input\_shared\_accounts) | n/a | `list(string)` | `null` | no |
234234
| <a name="input_shared_kms_key_arns"></a> [shared\_kms\_key\_arns](#input\_shared\_kms\_key\_arns) | n/a | `list(string)` | `[]` | no |
235235
| <a name="input_ssh_user"></a> [ssh\_user](#input\_ssh\_user) | SSH username | `string` | `null` | no |
236-
| <a name="input_stage_input"></a> [stage\_input](#input\_stage\_input) | Tags to be attached to the CodePipeline | <pre>list(object({<br> name = string,<br> category = string,<br> owner = string,<br> provider = string,<br> input_artifacts = list(string),<br> output_artifacts = list(string)<br> }))</pre> | <pre>[<br> {<br> "category": "Build",<br> "input_artifacts": [<br> "SourceOutput",<br> "SourceAnsibleOutput"<br> ],<br> "name": "build",<br> "output_artifacts": [<br> "BuildOutput"<br> ],<br> "owner": "AWS",<br> "provider": "CodeBuild"<br> },<br> {<br> "category": "Build",<br> "input_artifacts": [<br> "SourceOutput",<br> "SourceGossOutput"<br> ],<br> "name": "test",<br> "output_artifacts": [<br> "BuildTestOutput"<br> ],<br> "owner": "AWS",<br> "provider": "CodeBuild"<br> }<br>]</pre> | no |
237236
| <a name="input_state"></a> [state](#input\_state) | n/a | <pre>object({<br> bucket = string<br> key = string<br> region = string<br> dynamodb_table = string<br> })</pre> | n/a | yes |
238237
| <a name="input_terraform_version"></a> [terraform\_version](#input\_terraform\_version) | n/a | `string` | `"1.3.10"` | no |
239238
| <a name="input_test_project_source"></a> [test\_project\_source](#input\_test\_project\_source) | Source Code Repo for Goss Testing Suite | `string` | `"CODEPIPELINE"` | no |
@@ -249,11 +248,11 @@ HappyPathway
249248
| <a name="output_codepipeline_arn"></a> [codepipeline\_arn](#output\_codepipeline\_arn) | The ARN of the CodePipeline |
250249
| <a name="output_codepipeline_name"></a> [codepipeline\_name](#output\_codepipeline\_name) | The Name of the CodePipeline |
251250
| <a name="output_iam_arn"></a> [iam\_arn](#output\_iam\_arn) | The ARN of the IAM Role used by the CodePipeline |
252-
| <a name="output_kms_arn"></a> [kms\_arn](#output\_kms\_arn) | The ARN of the KMS key used in the codepipeline |
251+
| <a name="output_kms_arn"></a> [kms\_arn](#output\_kms\_arn) | The KMS key ARN used in the codepipeline |
253252
| <a name="output_managed_parameters"></a> [managed\_parameters](#output\_managed\_parameters) | n/a |
253+
| <a name="output_role_name"></a> [role\_name](#output\_role\_name) | The name of the IAM role used for build and pipeline operations |
254254
| <a name="output_s3_arn"></a> [s3\_arn](#output\_s3\_arn) | The ARN of the S3 Bucket |
255255
| <a name="output_s3_bucket"></a> [s3\_bucket](#output\_s3\_bucket) | The Name of the S3 Bucket |
256256
| <a name="output_sec_group"></a> [sec\_group](#output\_sec\_group) | n/a |
257257
| <a name="output_secrets"></a> [secrets](#output\_secrets) | n/a |
258-
| <a name="output_user"></a> [user](#output\_user) | n/a |
259258
<!-- END_TF_DOCS -->

0 commit comments

Comments
 (0)