forked from aws-samples/serverless-rds-proxy-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·53 lines (46 loc) · 2.16 KB
/
deploy.sh
File metadata and controls
executable file
·53 lines (46 loc) · 2.16 KB
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
samlocal deploy -t rds-with-proxy.yaml\
--stack-name sam-infra \
--region us-east-1 \
--capabilities CAPABILITY_IAM \
--no-fail-on-empty-changeset \
--no-confirm-changeset
samlocal list stack-outputs \
--stack-name sam-infra \
--region us-east-1 \
--output json > output-infra.json
vpc_id=$(jq -r '.[] | select(.OutputKey=="vpcId") | .OutputValue' output-infra.json)
subnet_ids=$(jq -r '.[] | select(.OutputKey=="subnetIds") | .OutputValue' output-infra.json)
cluster_endpoint=$(jq -r '.[] | select(.OutputKey=="clusterEndpoint") | .OutputValue' output-infra.json)
rds_proxy_endpoint=$(jq -r '.[] | select(.OutputKey=="rdsProxyEndpoint") | .OutputValue' output-infra.json)
db_proxy_resource_id=$(jq -r '.[] | select(.OutputKey=="dbProxyResourceId") | .OutputValue' output-infra.json)
database_port=$(jq -r '.[] | select(.OutputKey=="databasePort") | .OutputValue' output-infra.json)
secret_arn=$(jq -r '.[] | select(.OutputKey=="secretArn") | .OutputValue' output-infra.json)
lambda_sg_group_id=$(jq -r '.[] | select(.OutputKey=="lambdaSgGroupId") | .OutputValue' output-infra.json)
samlocal build --use-container
samlocal deploy \
--stack-name sam-app \
--region us-east-1 \
--capabilities CAPABILITY_IAM \
--no-fail-on-empty-changeset \
--no-confirm-changeset \
--resolve-s3 \
--parameter-overrides \
Vpc=$vpc_id \
Subnets=$subnet_ids \
RdsEndpoint=$cluster_endpoint \
RdsProxyEndpoint=$rds_proxy_endpoint \
ProxyResourceId=$db_proxy_resource_id \
Port=$database_port \
SecretArn=$secret_arn \
CreateFunctionSecurityGroup=True \
LambdaSecurityGroupId=$lambda_sg_group_id
samlocal list stack-outputs \
--stack-name sam-app \
--region us-east-1 \
--output json > output-app.json
api_base_path=$(jq -r '.[] | select(.OutputKey=="ApiBasePath") | .OutputValue' output-app.json)
api_base_path=${api_base_path%.*}
api_base_path=${api_base_path%.*}
yq e '.config.target = "'${api_base_path}.localhost.localstack.cloud:4566'"' -i load-no-proxy.yml
yq e '.config.target = "'${api_base_path}.localhost.localstack.cloud:4566'"' -i load-proxy.yml
python create-user.py