-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshippable.yml
102 lines (96 loc) · 3.12 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
resources:
# Automation scripts repo
- name: aws_redis_tf_repo
type: gitRepo
integration: "drship_github"
versionTemplate:
sourceName: "sample-organisation/prov_aws_redis_terraform" #TODO change to devops-recipes
branch: master
# AWS credentials
- name: aws_redis_tf_creds
type: integration
integration: "drship_aws"
# Terraform State
- name: aws_redis_tf_state
type: state
# Output of Amazon ElastiCache Redis provisioning
- name: aws_redis_tf_info
type: params
versionTemplate:
params:
SEED: "initial_version"
templates: &terraform-init
- pushd $(shipctl get_resource_state "aws_redis_tf_repo")
- export AWS_ACCESS_KEY_ID=$(shipctl get_integration_resource_field aws_redis_tf_creds "accessKey")
- export AWS_SECRET_ACCESS_KEY=$(shipctl get_integration_resource_field aws_redis_tf_creds "secretKey")
- shipctl copy_file_from_resource_state aws_redis_tf_state terraform.tfstate .
- shipctl replace terraform.tfvars
- terraform init
jobs:
# Provision Amazon ElastiCache Redis with Terraform
- name: prov_aws_redis_tf
type: runSh
steps:
- IN: aws_vpc_tf_info
- IN: aws_redis_tf_repo
switch: off
- IN: aws_redis_tf_state
switch: off
- IN: aws_redis_tf_creds
switch: off
- TASK:
name: prov_aws_elasticache_redis
runtime:
options:
env:
- aws_region: "us-east-1"
script:
- *terraform-init
- terraform apply -auto-approve -var-file=terraform.tfvars
- OUT: aws_redis_tf_info
overwrite: true
- OUT: aws_redis_tf_state
on_success:
script:
- shipctl put_resource_state_multi aws_redis_tf_info "engine_version=$(terraform output engine_version)" "port=$(terraform output port)" "cache_node_0_address=$(terraform output cache_node_0_address)" "cache_nodes_0_availability_zone=$(terraform output cache_nodes_0_availability_zone)"
- shipctl put_resource_state_multi aws_redis_tf_info "subnet_id=$(terraform output subnet_id)" "subnet_group_name=$(terraform output subnet_group_name)"
always:
script:
- shipctl copy_file_to_resource_state terraform.tfstate aws_redis_tf_state
- popd
flags:
- aws_elasticache
- redis
- aws
- terraform
# De-provision Amazon ElastiCache Redis with Terraform
- name: deprov_aws_redis_tf
type: runSh
steps:
- IN: aws_redis_tf_repo
switch: off
- IN: aws_redis_tf_state
switch: off
- IN: aws_redis_tf_creds
switch: off
- IN: aws_redis_tf_info
switch: off
- TASK:
name: deprov_aws_elasticache_redis
runtime:
options:
env:
- aws_region: "us-east-1"
script:
- *terraform-init
- terraform destroy -force -auto-approve -var-file=terraform.tfvars
- OUT: aws_redis_tf_state
always:
script:
- shipctl copy_file_to_resource_state terraform.tfstate aws_redis_tf_state
- popd
flags:
- aws_elasticache
- redis
- aws
- terraform