-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathterraform.sh
executable file
·41 lines (30 loc) · 1.21 KB
/
terraform.sh
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
#!/bin/bash
set -x
if [ ! -e host_key ]; then
ssh-keygen -t rsa -f host_key -N ''
fi
if [ ! -e worker_key ]; then
ssh-keygen -t rsa -f worker_key -N ''
fi
if [ ! -e session_signing_key ]; then
ssh-keygen -t rsa -f session_signing_key -N ''
fi
cp worker_key.pub authorized_worker_keys
subnet_id=$CONCOURSE_SUBNET_ID
vpc_id=$(aws ec2 describe-subnets --subnet-id $subnet_id | jq -r .Subnets[].VpcId)
echo $vpc_id
subcommand=$1; shift;
if [ "$subcommand" = 'get' ]; then
terraform $subcommand "$@"
exit $?
fi
terraform $subcommand -var aws_region=ap-northeast-1 -var availability_zones=ap-northeast-1a,ap-northeast-1c -var key_name=cw_kuoka -var subnet_id=$CONCOURSE_DB_SUBNET_IDS -var vpc_id=$vpc_id -var db_instance_class=db.t2.micro -var db_username=concourse -var db_password=concourse -var db_subnet_ids=$CONCOURSE_DB_SUBNET_IDS \
-var tsa_host_key=host_key \
-var session_signing_key=session_signing_key \
-var tsa_authorized_keys=worker_key.pub \
-var tsa_public_key=host_key.pub \
-var tsa_worker_private_key=worker_key \
-var ami=$(./my-latest-ami.sh) \
-var in_access_allowed_cidrs=$CONCOURSE_IN_ACCESS_ALLOWED_CIDRS \
-var worker_instance_profile=$CONCOURSE_WORKER_INSTANCE_PROFILE \
"$@"