Skip to content

Commit 340e2b2

Browse files
djaboxxroknsoundgithub-actions[bot]arnol377
authored
Enhance CodePipeline configuration by adding Pip configuration source… (#11)
* Enhance CodePipeline configuration by adding Pip configuration source and updating local variables for build and test stages * terraform-docs: automated action * Update terraform-plan.yaml * Update terraform-plan.yaml * Update terraform-plan.yaml * Autoformatting TF Code * terraform-docs: automated action * Update variables.tf * terraform-docs: automated action * Update terraform-plan.yaml --------- Co-authored-by: Dave Arnold <dave@roknsound.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: arnol377 <david.j.arnold.jr@census.gov>
1 parent 55828c8 commit 340e2b2

File tree

14 files changed

+156
-310
lines changed

14 files changed

+156
-310
lines changed

.github/workflows/terraform-plan.yaml

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
# This workflow contains a single job called "build"
1414
build:
1515
# The type of runner that the job will run on
16-
runs-on: [ terraform-aws-image-pipeline ]
16+
runs-on: [ ubuntu-latest ]
1717
env:
1818
AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
1919
AWS_ACCESS_KEY_ID: "${{ vars.AWS_ACCESS_KEY_ID }}"
@@ -28,11 +28,11 @@ jobs:
2828
ref: ${{ github.head_ref }}
2929
token: ${{ secrets.GH_TOKEN }}
3030

31-
- uses: CSVD/gh-actions-setup-node@v3
31+
- uses: actions/setup-node@v4
3232
with:
3333
node-version: 16
3434

35-
- uses: CSVD/gh-actions-setup-terraform@v2
35+
- uses: hashicorp/setup-terraform@v3.1.2
3636
with:
3737
terraform_version: ${{ vars.terraform_version }}
3838

@@ -54,28 +54,14 @@ jobs:
5454

5555
- name: Terraform Init
5656
id: init
57-
58-
working-directory: ./examples
59-
6057
run: terraform init -upgrade
6158

6259
- name: Terraform Validate
6360
id: validate
64-
65-
working-directory: ./examples
66-
6761
run: terraform validate
6862

69-
- name: Terraform Plan
70-
id: plan
71-
72-
working-directory: ./examples
73-
74-
run: terraform plan
75-
continue-on-error: true
76-
7763
- name: Update Pull Request
78-
uses: CSVD/gh-actions-github-script@v6
64+
uses: actions/github-script@v6
7965
if: github.event_name == 'pull_request'
8066
with:
8167
github-token: ${{ secrets.GH_TOKEN }}

.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
@@ -13,8 +13,8 @@
1313

1414
| Name | Version |
1515
|------|---------|
16-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.86.0 |
17-
| <a name="provider_random"></a> [random](#provider\_random) | 3.6.3 |
16+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.91.0 |
17+
| <a name="provider_random"></a> [random](#provider\_random) | 3.7.1 |
1818
| <a name="provider_tls"></a> [tls](#provider\_tls) | 4.0.6 |
1919

2020
## Modules
@@ -32,6 +32,9 @@
3232

3333
| Name | Type |
3434
|------|------|
35+
| [aws_iam_instance_profile.build_user_instance_profile](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_instance_profile) | resource |
36+
| [aws_iam_role.build_user_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
37+
| [aws_iam_role_policy.build_user_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource |
3538
| [aws_key_pair.deployer](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/key_pair) | resource |
3639
| [aws_secretsmanager_secret.secrets](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret) | resource |
3740
| [aws_secretsmanager_secret.ssh_key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret) | resource |
@@ -55,9 +58,7 @@
5558
| Name | Description | Type | Default | Required |
5659
|------|-------------|------|---------|:--------:|
5760
| <a name="input_ami"></a> [ami](#input\_ami) | n/a | <pre>object({<br> instance_type = string<br> source_ami = string<br> })</pre> | `null` | no |
58-
| <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 |
59-
| <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 |
60-
| <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 |
61+
| <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 |
6162
| <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 |
6263
| <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 |
6364
| <a name="input_build_project_source"></a> [build\_project\_source](#input\_build\_project\_source) | Source Code Repo for Playbook | `string` | `"CODEPIPELINE"` | no |
@@ -69,24 +70,23 @@
6970
| <a name="input_builder_images"></a> [builder\_images](#input\_builder\_images) | n/a | `map(string)` | `{}` | no |
7071
| <a name="input_builder_type"></a> [builder\_type](#input\_builder\_type) | Type of codebuild run environment | `string` | `"LINUX_CONTAINER"` | no |
7172
| <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 |
73+
| <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 |
7274
| <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 |
7375
| <a name="input_docker_build"></a> [docker\_build](#input\_docker\_build) | n/a | `bool` | `false` | no |
7476
| <a name="input_extra_parameters"></a> [extra\_parameters](#input\_extra\_parameters) | n/a | `map(string)` | `{}` | no |
7577
| <a name="input_goss_binary"></a> [goss\_binary](#input\_goss\_binary) | GOSS Profile to be used for testing | `string` | `"goss-linux-amd64"` | no |
76-
| <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 |
78+
| <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 |
7779
| <a name="input_goss_profile"></a> [goss\_profile](#input\_goss\_profile) | GOSS Profile to be used for testing | `string` | `"goss"` | no |
78-
| <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 |
79-
| <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 |
8080
| <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 |
8181
| <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 |
82+
| <a name="input_instance_profile"></a> [instance\_profile](#input\_instance\_profile) | n/a | `string` | `null` | no |
8283
| <a name="input_kms_key_id"></a> [kms\_key\_id](#input\_kms\_key\_id) | n/a | `string` | `null` | no |
8384
| <a name="input_nonmanaged_parameters"></a> [nonmanaged\_parameters](#input\_nonmanaged\_parameters) | n/a | `list(string)` | <pre>[<br> "dest_tag"<br>]</pre> | no |
84-
| <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 |
85+
| <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 |
8586
| <a name="input_packer_config"></a> [packer\_config](#input\_packer\_config) | Name of Packer Config in Repo | `string` | `"build.pkr.hcl"` | no |
86-
| <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 |
87-
| <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 |
8887
| <a name="input_packer_version"></a> [packer\_version](#input\_packer\_version) | Terraform CLI Version | `string` | `"1.10.3"` | no |
8988
| <a name="input_parameter_arns"></a> [parameter\_arns](#input\_parameter\_arns) | n/a | `list(string)` | `null` | no |
89+
| <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 |
9090
| <a name="input_playbook"></a> [playbook](#input\_playbook) | n/a | `string` | `null` | no |
9191
| <a name="input_project_name"></a> [project\_name](#input\_project\_name) | Unique name for this project | `string` | n/a | yes |
9292
| <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 |
@@ -95,7 +95,6 @@
9595
| <a name="input_shared_accounts"></a> [shared\_accounts](#input\_shared\_accounts) | n/a | `list(string)` | `null` | no |
9696
| <a name="input_shared_kms_key_arns"></a> [shared\_kms\_key\_arns](#input\_shared\_kms\_key\_arns) | n/a | `list(string)` | `[]` | no |
9797
| <a name="input_ssh_user"></a> [ssh\_user](#input\_ssh\_user) | SSH username | `string` | `null` | no |
98-
| <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 |
9998
| <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 |
10099
| <a name="input_terraform_version"></a> [terraform\_version](#input\_terraform\_version) | n/a | `string` | `"1.3.10"` | no |
101100
| <a name="input_test_project_source"></a> [test\_project\_source](#input\_test\_project\_source) | Source Code Repo for Goss Testing Suite | `string` | `"CODEPIPELINE"` | no |
@@ -111,11 +110,11 @@
111110
| <a name="output_codepipeline_arn"></a> [codepipeline\_arn](#output\_codepipeline\_arn) | The ARN of the CodePipeline |
112111
| <a name="output_codepipeline_name"></a> [codepipeline\_name](#output\_codepipeline\_name) | The Name of the CodePipeline |
113112
| <a name="output_iam_arn"></a> [iam\_arn](#output\_iam\_arn) | The ARN of the IAM Role used by the CodePipeline |
114-
| <a name="output_kms_arn"></a> [kms\_arn](#output\_kms\_arn) | The ARN of the KMS key used in the codepipeline |
113+
| <a name="output_kms_arn"></a> [kms\_arn](#output\_kms\_arn) | The KMS key ARN used in the codepipeline |
115114
| <a name="output_managed_parameters"></a> [managed\_parameters](#output\_managed\_parameters) | n/a |
115+
| <a name="output_role_name"></a> [role\_name](#output\_role\_name) | The name of the IAM role used for build and pipeline operations |
116116
| <a name="output_s3_arn"></a> [s3\_arn](#output\_s3\_arn) | The ARN of the S3 Bucket |
117117
| <a name="output_s3_bucket"></a> [s3\_bucket](#output\_s3\_bucket) | The Name of the S3 Bucket |
118118
| <a name="output_sec_group"></a> [sec\_group](#output\_sec\_group) | n/a |
119119
| <a name="output_secrets"></a> [secrets](#output\_secrets) | n/a |
120-
| <a name="output_user"></a> [user](#output\_user) | n/a |
121120
<!-- END_TF_DOCS -->

main.tf

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,10 @@ module "codepipeline_iam_role" {
8181
project_name = var.project_name
8282
create_new_role = var.create_new_role
8383
codepipeline_iam_role_name = var.create_new_role == true ? "${var.project_name}-codepipeline-role" : var.codepipeline_iam_role_name
84-
packer_repo = var.packer_repo
8584
packer_bucket = var.packer_bucket
86-
ansible_repo = var.ansible_repo
8785
ansible_bucket = var.ansible_bucket
88-
goss_repo = var.goss_repo
8986
goss_bucket = var.goss_bucket
87+
pip_bucket = var.pip_bucket
9088
image = var.image
9189
kms_key_arn = module.codepipeline_kms.arn
9290
shared_kms_key_arns = var.shared_kms_key_arns
@@ -121,21 +119,12 @@ module "codepipeline_terraform" {
121119

122120
project_name = var.project_name
123121

124-
packer_source_type = var.packer_source_type
125-
packer_repo = var.packer_repo
126-
packer_bucket = var.packer_bucket
127-
128-
ansible_source_type = var.ansible_source_type
129-
ansible_repo = var.ansible_repo
130-
ansible_bucket = var.ansible_bucket
131-
132-
goss_source_type = var.goss_source_type
133-
goss_repo = var.goss_repo
134-
goss_bucket = var.goss_bucket
135-
122+
packer_bucket = var.packer_bucket
123+
ansible_bucket = var.ansible_bucket
124+
goss_bucket = var.goss_bucket
125+
pip_bucket = var.pip_bucket
136126
s3_bucket_name = module.s3_artifacts_bucket.bucket
137127
codepipeline_role_arn = module.codepipeline_iam_role.role_arn
138-
stages = var.stage_input
139128
kms_key_arn = module.codepipeline_kms.arn
140129
tags = {
141130
Project_Name = var.project_name
@@ -168,8 +157,8 @@ resource "aws_iam_role" "build_user_role" {
168157
}
169158

170159
resource "aws_iam_role_policy" "build_user_policy" {
171-
name = "${var.project_name}-build-user-policy"
172-
role = aws_iam_role.build_user_role.id
160+
name = "${var.project_name}-build-user-policy"
161+
role = aws_iam_role.build_user_role.id
173162
policy = local.build_user_iam_policy
174163
}
175164

0 commit comments

Comments
 (0)