Update packer-ami.pkr.hcl

This commit is contained in:
Ryan Malloy 2024-11-12 18:15:34 +00:00
parent 1a1fbbe6d1
commit 116fc54f2e
1 changed files with 10 additions and 7 deletions

View File

@ -6,14 +6,9 @@ packer {
} }
} }
} }
variable "AWSAccessKeyID" {}
variable "AWSSecretAccessKey" {}
source "amazon-ebs" "ubuntu" { source "amazon-ebs" "ubuntu" {
ami_name = "gitlab-runner-manager-packer-ami" ami_name = "packer-ami"
instance_type = "t2.nano" instance_type = "t2.nano"
region = <VALUE>
source_ami_filter { source_ami_filter {
filters = { filters = {
name = "ubuntu/images/*ubuntu-jammy-22.04-amd64-server-*" name = "ubuntu/images/*ubuntu-jammy-22.04-amd64-server-*"
@ -51,13 +46,21 @@ build {
"mkdir ~/.aws" "mkdir ~/.aws"
] ]
} }
provisioner "file" { provisioner "file" {
source = "aws-config" source = "aws-config"
destination = "~/.aws/config" destination = "~/.aws/config"
} }
provisioner "file" { provisioner "file" {
source = "aws-creds" source = "aws-creds"
destination = "~/.aws/credentials" destination = "~/.aws/credentials"
} }
provisioner "shell" {
inline = [
"sed -i 's|aKeyID|${var.AWS_ACCESS_KEY_ID}|' ~/.aws/credentials",
"sed -i 's|aSecretAccessKey|${var.AWS_SECRET_ACCESS_KEY}|' ~/.aws/credentials"
]
}
} }