Skip to content

Commit

Permalink
feat: Make Packer builder IAM role configurable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mattgodbolt committed Jan 8, 2025
1 parent 1ccc57f commit d9ee487
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 0 deletions.
7 changes: 7 additions & 0 deletions images/linux-al2023/github_agent.linux.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ variable "instance_type" {
default = "m3.medium"
}

variable "iam_instance_profile" {
description = "The IAM instance profile to run the builder as"
type = string
default = ""
}

variable "root_volume_size_gb" {
type = number
default = 8
Expand Down Expand Up @@ -103,6 +109,7 @@ source "amazon-ebs" "githubrunner" {
subnet_id = var.subnet_id
associate_public_ip_address = var.associate_public_ip_address
temporary_security_group_source_public_ip = var.temporary_security_group_source_public_ip
iam_instance_profile = var.iam_instance_profile

source_ami_filter {
filters = {
Expand Down
7 changes: 7 additions & 0 deletions images/ubuntu-focal/github_agent.ubuntu.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ variable "instance_type" {
default = "t3.medium"
}

variable "iam_instance_profile" {
description = "The IAM instance profile to run the builder as"
type = string
default = ""
}

variable "root_volume_size_gb" {
type = number
default = 8
Expand Down Expand Up @@ -103,6 +109,7 @@ source "amazon-ebs" "githubrunner" {
subnet_id = var.subnet_id
associate_public_ip_address = var.associate_public_ip_address
temporary_security_group_source_public_ip = var.temporary_security_group_source_public_ip
iam_instance_profile = var.iam_instance_profile

source_ami_filter {
filters = {
Expand Down
7 changes: 7 additions & 0 deletions images/ubuntu-jammy-arm64/github_agent.ubuntu.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ variable "instance_type" {
default = "t4g.small"
}

variable "iam_instance_profile" {
description = "The IAM instance profile to run the builder as"
type = string
default = ""
}

variable "root_volume_size_gb" {
type = number
default = 8
Expand Down Expand Up @@ -103,6 +109,7 @@ source "amazon-ebs" "githubrunner" {
subnet_id = var.subnet_id
associate_public_ip_address = var.associate_public_ip_address
temporary_security_group_source_public_ip = var.temporary_security_group_source_public_ip
iam_instance_profile = var.iam_instance_profile

source_ami_filter {
filters = {
Expand Down
7 changes: 7 additions & 0 deletions images/ubuntu-jammy/github_agent.ubuntu.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ variable "instance_type" {
default = "t3.medium"
}

variable "iam_instance_profile" {
description = "The IAM instance profile to run the builder as"
type = string
default = ""
}

variable "root_volume_size_gb" {
type = number
default = 8
Expand Down Expand Up @@ -103,6 +109,7 @@ source "amazon-ebs" "githubrunner" {
subnet_id = var.subnet_id
associate_public_ip_address = var.associate_public_ip_address
temporary_security_group_source_public_ip = var.temporary_security_group_source_public_ip
iam_instance_profile = var.iam_instance_profile

source_ami_filter {
filters = {
Expand Down
7 changes: 7 additions & 0 deletions images/windows-core-2019/github_agent.windows.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ variable "instance_type" {
default = "t3a.medium"
}

variable "iam_instance_profile" {
description = "The IAM instance profile to run the builder as"
type = string
default = ""
}

variable "ebs_delete_on_termination" {
description = "Indicates whether the EBS volume is deleted on instance termination."
type = bool
Expand Down Expand Up @@ -67,6 +73,7 @@ source "amazon-ebs" "githubrunner" {
region = var.region
associate_public_ip_address = var.associate_public_ip_address
temporary_security_group_source_public_ip = var.temporary_security_group_source_public_ip
iam_instance_profile = var.iam_instance_profile

source_ami_filter {
filters = {
Expand Down
7 changes: 7 additions & 0 deletions images/windows-core-2022/github_agent.windows.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ variable "security_group_id" {
default = null
}

variable "iam_instance_profile" {
description = "The IAM instance profile to run the builder as"
type = string
default = ""
}

variable "subnet_id" {
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"
type = string
Expand Down Expand Up @@ -80,6 +86,7 @@ source "amazon-ebs" "githubrunner" {
subnet_id = var.subnet_id
associate_public_ip_address = var.associate_public_ip_address
temporary_security_group_source_public_ip = var.temporary_security_group_source_public_ip
iam_instance_profile = var.iam_instance_profile

source_ami_filter {
filters = {
Expand Down

0 comments on commit d9ee487

Please sign in to comment.