Skip to content

Commit 418a8f8

Browse files
authored
Merge pull request #7 from SPHTech-Platform/bugfix/codebuild-iam-inline
added inline policy for codebuild for additional permission
2 parents 33bf61e + 6dd96aa commit 418a8f8

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ on:
44
push:
55
branches:
66
- main
7+
8+
permissions:
9+
actions: read
10+
checks: read
11+
contents: read
12+
pull-requests: read
13+
714
jobs:
815
ci:
916
uses: SPHTech-Platform/reusable-workflows/.github/workflows/terraform.yaml@main

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
| Name | Version |
77
|------|---------|
8-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
8+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
99
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.24 |
1010

1111
## Providers
@@ -28,12 +28,14 @@
2828
| [aws_codebuild_project.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codebuild_project) | resource |
2929
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
3030
| [aws_iam_policy_document.codebuild](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
31+
| [aws_iam_policy_document.codebuild_inline_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
3132
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
3233

3334
## Inputs
3435

3536
| Name | Description | Type | Default | Required |
3637
|------|-------------|------|---------|:--------:|
38+
| <a name="input_additional_iam"></a> [additional\_iam](#input\_additional\_iam) | Additional IAM Policy Document for Codebuild | `list(any)` | `[]` | no |
3739
| <a name="input_additional_policy_arns"></a> [additional\_policy\_arns](#input\_additional\_policy\_arns) | Additional policies to be added to the IAM role. | `list(string)` | `[]` | no |
3840
| <a name="input_artifacts"></a> [artifacts](#input\_artifacts) | Artifacts configuration block. | <pre>object({<br> type = string # Valid values are CODEPIPELINE, NO_ARTIFACTS, S3<br> name = optional(string)<br> location = optional(string)<br> })</pre> | <pre>{<br> "type": "NO_ARTIFACTS"<br>}</pre> | no |
3941
| <a name="input_artifacts_bucket_name"></a> [artifacts\_bucket\_name](#input\_artifacts\_bucket\_name) | Name of the artifacts bucket | `string` | `""` | no |
@@ -44,7 +46,6 @@
4446
| <a name="input_build_type"></a> [build\_type](#input\_build\_type) | Type of build environment to use for related builds. | `string` | `"LINUX_CONTAINER"` | no |
4547
| <a name="input_buildspec"></a> [buildspec](#input\_buildspec) | The build spec declaration to use for this build project's related builds. | `string` | `""` | no |
4648
| <a name="input_cache"></a> [cache](#input\_cache) | Cache configuration block. | <pre>object({<br> type = optional(string) # Valid values: NO_CACHE, LOCAL, S3. Defaults to NO_CACHE.<br> modes = optional(list(string)) # Required when cache type is LOCAL<br> location = optional(string) # Required when cache type is S3<br> })</pre> | `{}` | no |
47-
| <a name="input_codestar_arn"></a> [codestar\_arn](#input\_codestar\_arn) | Codestar ARN for connecting to Github. | `string` | n/a | yes |
4849
| <a name="input_create_service_role"></a> [create\_service\_role](#input\_create\_service\_role) | Create new IAM service role and policy if `true`. | `bool` | `true` | no |
4950
| <a name="input_description"></a> [description](#input\_description) | Short description of the project. | `string` | n/a | yes |
5051
| <a name="input_encryption_key_arn"></a> [encryption\_key\_arn](#input\_encryption\_key\_arn) | AWS Key Management Service (AWS KMS) customer master key (CMK) to be used for encrypting the build project's build output artifacts. | `string` | `null` | no |
@@ -63,5 +64,6 @@
6364
|------|-------------|
6465
| <a name="output_arn"></a> [arn](#output\_arn) | CodeBuild ARN. |
6566
| <a name="output_id"></a> [id](#output\_id) | CodeBuild Id. |
67+
| <a name="output_name"></a> [name](#output\_name) | CodeBuild name. |
6668
| <a name="output_service_role_arn"></a> [service\_role\_arn](#output\_service\_role\_arn) | CodeBuild service role ARN. |
6769
<!-- END_TF_DOCS -->

iam.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ module "codebuild_service_role_policy" {
2525
name = "${var.name}-iam-policy"
2626
path = "/"
2727
description = "${var.name} IAM Policy"
28-
policy = data.aws_iam_policy_document.codebuild.json
28+
policy = data.aws_iam_policy_document.codebuild_inline_policy.json
29+
}
30+
31+
data "aws_iam_policy_document" "codebuild_inline_policy" {
32+
source_policy_documents = concat([
33+
data.aws_iam_policy_document.codebuild.json,
34+
], var.additional_iam)
2935
}
3036

3137
data "aws_iam_policy_document" "codebuild" {

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,9 @@ variable "report_build_status" {
134134
type = bool
135135
default = false
136136
}
137+
138+
variable "additional_iam" {
139+
description = "Additional IAM Policy Document for Codebuild"
140+
type = list(any)
141+
default = []
142+
}

0 commit comments

Comments
 (0)