Skip to content

Commit 4a6b49e

Browse files
committed
Allow role name override
1 parent 297b29d commit 4a6b49e

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ locals {
2323
}
2424

2525
resource "aws_iam_role" "this" {
26-
name = "github-actions-${md5(data.aws_iam_policy_document.this.json)}"
26+
name = coalesce(var.iam_role_name, "github-actions-${md5(data.aws_iam_policy_document.this.json)}")
2727

2828
assume_role_policy = data.aws_iam_policy_document.this.json
2929
max_session_duration = var.max_session_duration

variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/i
6464
EOS
6565
}
6666

67+
variable "iam_role_name" {
68+
type = string
69+
default = null
70+
71+
description = <<EOS
72+
Custom name for the IAM role. If not provided, the name will be automatically
73+
generated as `github-actions-<md5>` based on the assume role policy document.
74+
EOS
75+
}
76+
6777
variable "iam_role_tags" {
6878
type = map(string)
6979
default = {}

0 commit comments

Comments
 (0)