Update packer-ami.pkr.hcl
This commit is contained in:
parent
1a1fbbe6d1
commit
116fc54f2e
1 changed files with 10 additions and 7 deletions
66
packer-ami.pkr.hcl
Normal file
66
packer-ami.pkr.hcl
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
packer {
|
||||
required_plugins {
|
||||
amazon = {
|
||||
version = ">= 1.2.8"
|
||||
source = "github.com/hashicorp/amazon"
|
||||
}
|
||||
}
|
||||
}
|
||||
source "amazon-ebs" "ubuntu" {
|
||||
ami_name = "packer-ami"
|
||||
instance_type = "t2.nano"
|
||||
source_ami_filter {
|
||||
filters = {
|
||||
name = "ubuntu/images/*ubuntu-jammy-22.04-amd64-server-*"
|
||||
root-device-type = "ebs"
|
||||
virtualization-type = "hvm"
|
||||
}
|
||||
most_recent = true
|
||||
owners = ["099720109477"]
|
||||
}
|
||||
ssh_username = "ubuntu"
|
||||
}
|
||||
|
||||
build {
|
||||
name = "runner-manager-ami-packer"
|
||||
sources = [
|
||||
"source.amazon-ebs.ubuntu"
|
||||
]
|
||||
|
||||
provisioner "file" {
|
||||
source = "privateKey.pem"
|
||||
destination = "~/.ssh/key.pem"
|
||||
}
|
||||
provisioner "shell" {
|
||||
inline = [
|
||||
"chmod 400 ~/.ssh/key.pem"
|
||||
]
|
||||
}
|
||||
|
||||
provisioner "shell" {
|
||||
script = "install-docker.sh"
|
||||
}
|
||||
|
||||
provisioner "shell" {
|
||||
inline = [
|
||||
"mkdir ~/.aws"
|
||||
]
|
||||
}
|
||||
|
||||
provisioner "file" {
|
||||
source = "aws-config"
|
||||
destination = "~/.aws/config"
|
||||
}
|
||||
|
||||
provisioner "file" {
|
||||
source = "aws-creds"
|
||||
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"
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue