Skip to content

Commit

Permalink
fix: Update aws_iam_role_policy_attachment and make codebuild role ou…
Browse files Browse the repository at this point in the history
…tput optional (#49)
  • Loading branch information
andrewchees authored Dec 5, 2024
1 parent 3fb16d8 commit 212957a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,11 @@ No modules.

| Name | Description |
|------|-------------|
| <a name="output_codebuild_project"></a> [codebuild\_project](#output\_codebuild\_project) | Name and ARN of codebuild project, to be used when running GitHub Actions |
| <a name="output_codebuild_role"></a> [codebuild\_role](#output\_codebuild\_role) | Name and ARN of codebuild role, to be used when running GitHub Actions |
| <a name="output_ecr_repository"></a> [ecr\_repository](#output\_ecr\_repository) | Name and ARN of ECR repository, to be used when to push custom docker images for the codebuiild project |
| <a name="output_aws_security_group_id"></a> [aws\_security\_group\_id](#output\_aws\_security\_group\_id) | ID of the security group created for the codebuild project |
| <a name="output_codebuild_project_arn"></a> [codebuild\_project\_arn](#output\_codebuild\_project\_arn) | ARN of the codebuild project, to be used when running GitHub Actions |
| <a name="output_codebuild_project_name"></a> [codebuild\_project\_name](#output\_codebuild\_project\_name) | Name of the codebuild project, to be used when running GitHub Actions |
| <a name="output_codebuild_role_name"></a> [codebuild\_role\_name](#output\_codebuild\_role\_name) | Name of the codebuild role, to be used when running GitHub Actions |
| <a name="output_ecr_repository_name"></a> [ecr\_repository\_name](#output\_ecr\_repository\_name) | Name of the ECR repository, to be used when to push custom docker images for the codebuiild project |

----
### Providers
Expand Down
7 changes: 2 additions & 5 deletions iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,8 @@ resource "aws_iam_role" "this" {
}

resource "aws_iam_role_policy_attachment" "additional" {
for_each = {
for k, v in var.iam_role_policies :
k => v if local.create_iam_role
}
for_each = var.iam_role_policies

role = aws_iam_role.this[0].name
role = local.create_iam_role ? aws_iam_role.this[0].name : var.iam_role_name
policy_arn = each.value
}
37 changes: 19 additions & 18 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
output "codebuild_project" {
value = {
name = aws_codebuild_project.this.name
arn = aws_codebuild_project.this.arn
}
description = "Name and ARN of codebuild project, to be used when running GitHub Actions"
output "codebuild_project_name" {
value = aws_codebuild_project.this.name
description = "Name of the codebuild project, to be used when running GitHub Actions"
}

output "codebuild_role" {
value = {
name = aws_iam_role.this[0].name
arn = aws_iam_role.this[0].arn
}
description = "Name and ARN of codebuild role, to be used when running GitHub Actions"
output "codebuild_project_arn" {
value = aws_codebuild_project.this.arn
description = "ARN of the codebuild project, to be used when running GitHub Actions"
}

output "ecr_repository" {
value = {
name = try(aws_ecr_repository.this[0].name, null)
arn = try(aws_ecr_repository.this[0].arn, null)
}
description = "Name and ARN of ECR repository, to be used when to push custom docker images for the codebuiild project"
output "codebuild_role_name" {
value = try(aws_iam_role.this[0].name, var.iam_role_name)
description = "Name of the codebuild role, to be used when running GitHub Actions"
}

output "ecr_repository_name" {
value = try(aws_ecr_repository.this[0].name, null)
description = "Name of the ECR repository, to be used when to push custom docker images for the codebuiild project"
}

output "aws_security_group_id" {
value = try(aws_security_group.codebuild[0].id, null)
description = "ID of the security group created for the codebuild project"
}

0 comments on commit 212957a

Please sign in to comment.