added packer and build script
This commit is contained in:
2
infra/custom_ami/packer/.gitignore
vendored
Normal file
2
infra/custom_ami/packer/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
manifest-*.json
|
||||
manifest-*.json.lock
|
||||
67
infra/custom_ami/packer/catherine-fc.json
Normal file
67
infra/custom_ami/packer/catherine-fc.json
Normal file
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"variables": {
|
||||
"vpc": "{{env `BUILD_VPC_ID`}}",
|
||||
"subnet": "{{env `BUILD_SUBNET_ID`}}",
|
||||
"PROFILE": "{{env `AWS_PROFILE`}}",
|
||||
"STAGE": "{{env `STAGE`}}",
|
||||
"AMI_BASENAME": "{{env `AMI_BASENAME`}}"
|
||||
},
|
||||
"builders": [
|
||||
{
|
||||
"type": "amazon-ebs",
|
||||
"name": "Custom AMI builder",
|
||||
"region": "ap-northeast-1",
|
||||
"source_ami": "ami-0cc75a8978fbbc969",
|
||||
"instance_type": "t3.small",
|
||||
"ssh_username": "ec2-user",
|
||||
"ami_name": "{{user `AMI_BASENAME`}}-{{user `STAGE`}}-{{timestamp}}",
|
||||
"tags": {
|
||||
"Name": "{{user `AMI_BASENAME`}}-{{user `STAGE`}}",
|
||||
"Base_AMI_ID": "{{ .SourceAMI }}",
|
||||
"Base_AMI_NAME": "{{ .SourceAMIName }}",
|
||||
"PROJECT": "CATHERINE_FC"
|
||||
},
|
||||
"run_tags": {
|
||||
"Name": "{{user `AMI_BASENAME`}}-{{user `STAGE`}}-packer",
|
||||
"PROJECT": "CATHERINE_FC"
|
||||
},
|
||||
"run_volume_tags": {
|
||||
"Name": "{{user `AMI_BASENAME`}}-{{user `STAGE`}}-packer",
|
||||
"PROJECT": "CATHERINE_FC"
|
||||
},
|
||||
"ami_description": "Amazon Linux 2 with NodeJS",
|
||||
"vpc_id": "{{user `vpc`}}",
|
||||
"subnet_id": "{{user `subnet`}}"
|
||||
}
|
||||
],
|
||||
"provisioners": [
|
||||
{
|
||||
"type": "shell",
|
||||
"inline": [
|
||||
"sudo yum update",
|
||||
"sudo yum -y install unzip",
|
||||
"sudo yum -y install nano",
|
||||
"sudo yum -y install dos2unix",
|
||||
"wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash",
|
||||
". ~/.nvm/nvm.sh",
|
||||
"nvm install 12"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"source": "../platform-uploads",
|
||||
"destination": "/tmp"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"inline": [
|
||||
"sudo chown -R root:root /tmp/platform-uploads",
|
||||
"sudo dos2unix /tmp/platform-uploads/opt/web-init/web-init.sh",
|
||||
"sudo cp -rf /tmp/platform-uploads/etc/* /etc/",
|
||||
"sudo cp -rf /tmp/platform-uploads/opt/* /opt/",
|
||||
"sudo systemctl enable web-init",
|
||||
"sudo rm -rf /tmp/platform-uploads"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
6
infra/custom_ami/packer/vars/prod/vars.json
Normal file
6
infra/custom_ami/packer/vars/prod/vars.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"vpc": "vpc-c54553a2",
|
||||
"subnet": "subnet-0d0fdf45",
|
||||
"STAGE": "prod",
|
||||
"AMI_BASENAME": "catherine-fc"
|
||||
}
|
||||
Reference in New Issue
Block a user