Skip to content

fix: Add aws_partition to support usage of this module in aws-cn and gov #670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.96.3
rev: v1.98.1
hooks:
- id: terraform_fmt
- id: terraform_wrapper_module_for_each
Expand Down
1 change: 1 addition & 0 deletions modules/deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ No modules.
| [aws_iam_role.codedeploy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_role) | data source |
| [aws_lambda_alias.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/lambda_alias) | data source |
| [aws_lambda_function.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/lambda_function) | data source |
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |

## Inputs

Expand Down
4 changes: 3 additions & 1 deletion modules/deploy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ EOF

}

data "aws_partition" "current" {}

data "aws_lambda_alias" "this" {
count = var.create && var.create_deployment ? 1 : 0

Expand Down Expand Up @@ -209,7 +211,7 @@ resource "aws_iam_role_policy_attachment" "codedeploy" {
count = var.create && var.create_codedeploy_role ? 1 : 0

role = try(aws_iam_role.codedeploy[0].id, "")
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSCodeDeployRoleForLambda"
policy_arn = "arn:${data.aws_partition.current.partition}:iam::aws:policy/service-role/AWSCodeDeployRoleForLambda"
}

data "aws_iam_policy_document" "hooks" {
Expand Down
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ output "lambda_function_arn" {

output "lambda_function_arn_static" {
description = "The static ARN of the Lambda Function. Use this to avoid cycle errors between resources (e.g., Step Functions)"
value = local.create && var.create_function && !var.create_layer ? "arn:aws:lambda:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:function:${var.function_name}" : ""
value = local.create && var.create_function && !var.create_layer ? "arn:${data.aws_partition.current.partition}:lambda:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:function:${var.function_name}" : ""
}

output "lambda_function_invoke_arn" {
Expand Down