forked from devops-recipes/aws_ami_with_packer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshippable.yml
58 lines (56 loc) · 1.82 KB
/
shippable.yml
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
resources:
# Automation scripts repo
- name: aws_ami_pack_repo
type: gitRepo
integration: "dr_gh"
versionTemplate:
sourceName: "devops-recipes/aws_ami_with_packer"
branch: master
# Output of Packer Image Build
- name: aws_ami_pack_info
type: params
versionTemplate:
params:
SEED: true
jobs:
# Build AWS AMI with Packer
- name: build_aws_ami_pack
type: runSh
integrations:
- dr_aws
steps:
- IN: aws_ami_pack_repo
- IN: aws_vpc_tf_info
switch: off
- IN: aws_vpc_tf_state
switch: off
- TASK:
name: build_ami
runtime:
options:
env:
#- vpc_id: "implicitly set from aws_vpc_tf_info"
#- vpc_region: "implicitly set from aws_vpc_tf_info"
#- vpc_public_sg_id: "implicitly set from aws_vpc_tf_info"
#- vpc_public_sn_id: "implicitly set from aws_vpc_tf_info"
- source_ami: "ami-43a15f3e"
- instance_type: "t2.micro"
- ssh_username: "ubuntu"
script:
- pushd $(shipctl get_resource_state "aws_ami_pack_repo")
- export AWS_ACCESS_KEY_ID=$(shipctl get_integration_field dr_aws "accessKey")
- export AWS_SECRET_ACCESS_KEY=$(shipctl get_integration_field dr_aws "secretKey")
- shipctl replace vars.json
- packer validate -var-file=vars.json baseAMI.json
- packer build -var-file=vars.json baseAMI.json
- AMI_ID=$(shipctl get_json_value manifest.json builds[0].artifact_id | cut -d':' -f 2)
- OUT: aws_ami_pack_info
overwrite: true
on_success:
script:
- shipctl post_resource_state aws_ami_pack_info versionName $AMI_ID
- popd
flags:
- aws_ami
- aws
- packer