Skip to content

Commit 16e2eb6

Browse files
committed
feat: Make Packer builder IAM role configurable
Allows the Packer build instance to access resources as a IAM role during the build process. Defaults to empty string, which should replicate existing behaviour. See #3041.
1 parent 1ccc57f commit 16e2eb6

File tree

6 files changed

+42
-0
lines changed

6 files changed

+42
-0
lines changed

images/linux-al2023/github_agent.linux.pkr.hcl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ variable "instance_type" {
4242
default = "m3.medium"
4343
}
4444

45+
variable "instance_iam_profile" {
46+
description = "The IAM instance profile to run the builder as"
47+
type = string
48+
default = ""
49+
}
50+
4551
variable "root_volume_size_gb" {
4652
type = number
4753
default = 8
@@ -103,6 +109,7 @@ source "amazon-ebs" "githubrunner" {
103109
subnet_id = var.subnet_id
104110
associate_public_ip_address = var.associate_public_ip_address
105111
temporary_security_group_source_public_ip = var.temporary_security_group_source_public_ip
112+
instance_iam_profile = var.instance_iam_profile
106113

107114
source_ami_filter {
108115
filters = {

images/ubuntu-focal/github_agent.ubuntu.pkr.hcl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ variable "instance_type" {
4242
default = "t3.medium"
4343
}
4444

45+
variable "instance_iam_profile" {
46+
description = "The IAM instance profile to run the builder as"
47+
type = string
48+
default = ""
49+
}
50+
4551
variable "root_volume_size_gb" {
4652
type = number
4753
default = 8
@@ -103,6 +109,7 @@ source "amazon-ebs" "githubrunner" {
103109
subnet_id = var.subnet_id
104110
associate_public_ip_address = var.associate_public_ip_address
105111
temporary_security_group_source_public_ip = var.temporary_security_group_source_public_ip
112+
instance_iam_profile = var.instance_iam_profile
106113

107114
source_ami_filter {
108115
filters = {

images/ubuntu-jammy-arm64/github_agent.ubuntu.pkr.hcl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ variable "instance_type" {
4242
default = "t4g.small"
4343
}
4444

45+
variable "instance_iam_profile" {
46+
description = "The IAM instance profile to run the builder as"
47+
type = string
48+
default = ""
49+
}
50+
4551
variable "root_volume_size_gb" {
4652
type = number
4753
default = 8
@@ -103,6 +109,7 @@ source "amazon-ebs" "githubrunner" {
103109
subnet_id = var.subnet_id
104110
associate_public_ip_address = var.associate_public_ip_address
105111
temporary_security_group_source_public_ip = var.temporary_security_group_source_public_ip
112+
instance_iam_profile = var.instance_iam_profile
106113

107114
source_ami_filter {
108115
filters = {

images/ubuntu-jammy/github_agent.ubuntu.pkr.hcl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ variable "instance_type" {
4242
default = "t3.medium"
4343
}
4444

45+
variable "instance_iam_profile" {
46+
description = "The IAM instance profile to run the builder as"
47+
type = string
48+
default = ""
49+
}
50+
4551
variable "root_volume_size_gb" {
4652
type = number
4753
default = 8
@@ -103,6 +109,7 @@ source "amazon-ebs" "githubrunner" {
103109
subnet_id = var.subnet_id
104110
associate_public_ip_address = var.associate_public_ip_address
105111
temporary_security_group_source_public_ip = var.temporary_security_group_source_public_ip
112+
instance_iam_profile = var.instance_iam_profile
106113

107114
source_ami_filter {
108115
filters = {

images/windows-core-2019/github_agent.windows.pkr.hcl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ variable "instance_type" {
2424
default = "t3a.medium"
2525
}
2626

27+
variable "instance_iam_profile" {
28+
description = "The IAM instance profile to run the builder as"
29+
type = string
30+
default = ""
31+
}
32+
2733
variable "ebs_delete_on_termination" {
2834
description = "Indicates whether the EBS volume is deleted on instance termination."
2935
type = bool
@@ -67,6 +73,7 @@ source "amazon-ebs" "githubrunner" {
6773
region = var.region
6874
associate_public_ip_address = var.associate_public_ip_address
6975
temporary_security_group_source_public_ip = var.temporary_security_group_source_public_ip
76+
instance_iam_profile = var.instance_iam_profile
7077

7178
source_ami_filter {
7279
filters = {

images/windows-core-2022/github_agent.windows.pkr.hcl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ variable "security_group_id" {
2424
default = null
2525
}
2626

27+
variable "instance_iam_profile" {
28+
description = "The IAM instance profile to run the builder as"
29+
type = string
30+
default = ""
31+
}
32+
2733
variable "subnet_id" {
2834
description = "If using VPC, the ID of the subnet, such as subnet-12345def, where Packer will launch the EC2 instance. This field is required if you are using an non-default VPC"
2935
type = string
@@ -80,6 +86,7 @@ source "amazon-ebs" "githubrunner" {
8086
subnet_id = var.subnet_id
8187
associate_public_ip_address = var.associate_public_ip_address
8288
temporary_security_group_source_public_ip = var.temporary_security_group_source_public_ip
89+
instance_iam_profile = var.instance_iam_profile
8390

8491
source_ami_filter {
8592
filters = {

0 commit comments

Comments
 (0)