-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjenkins.ami.pkr.hcl
78 lines (64 loc) · 1.6 KB
/
jenkins.ami.pkr.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
packer {
required_plugins {
amazon = {
source = "github.com/hashicorp/amazon"
version = "~> 1"
}
}
}
variable "aws_region" {
type = string
default = "us-east-1"
}
variable "ami_name" {
type = string
default = "jenkins-ami"
}
variable "team_account_ids" {
type = list(string)
default = ["058264431172"] # Replace with your team's AWS account IDs
}
source "amazon-ebs" "ubuntu" {
ami_name = "${var.ami_name}-{{timestamp}}"
instance_type = "t2.micro"
region = var.aws_region
source_ami = "ami-04b70fa74e45c3917"
ssh_username = "ubuntu"
communicator = "ssh"
# Ensure EBS volume is deleted on termination
launch_block_device_mappings {
device_name = "/dev/sda1"
delete_on_termination = true
volume_size = 8
volume_type = "gp2"
}
}
build {
sources = ["source.amazon-ebs.ubuntu"]
# Copy necessary files first
provisioner "file" {
source = "./jenkins/jenkins.yaml"
destination = "/home/ubuntu/jenkins.yaml"
}
provisioner "file" {
source = "./jenkins/plugins.txt"
destination = "/home/ubuntu/plugins.txt"
}
provisioner "file" {
source = "./jenkins/build-docker-image.groovy"
destination = "/home/ubuntu/build-docker-image.groovy"
}
provisioner "file" {
source = "./jenkins/Jenkinsfile"
destination = "/home/ubuntu/Jenkinsfile"
}
# provisioner "file" {
# source = "./K8s_config/config.yaml"
# destination = "/home/ubuntu/config.yaml"
# }
provisioner "shell" {
scripts = [
"./scripts/install.sh",
]
}
}