-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathdeploy.sh
executable file
·125 lines (116 loc) · 6.56 KB
/
deploy.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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env bash
target=
if [ $1 ] ; then
target="${1}-"
else
echo "You have to specify the target to deployment."
exit 1
fi
# SSMに登録するパラメータは、ALIS_APP_IDを含めた値がPrefixとして定義される
# See: https://github.com/AlisProject/environment
SSM_PARAMS_PREFIX=${ALIS_APP_ID}ssm
DEPLOY_BUCKET_NAME=${ALIS_APP_ID}-serverless-deploy-bucket
aws cloudformation package \
--template-file ${target}template.yaml \
--s3-bucket $DEPLOY_BUCKET_NAME \
--output-template-file ${target}packaged-template.yaml
aws cloudformation deploy \
--template-file ${target}packaged-template.yaml \
--s3-bucket $DEPLOY_BUCKET_NAME \
--stack-name ${ALIS_APP_ID}${1} \
--parameter-overrides \
AlisAppId=${ALIS_APP_ID} \
AlisAppDomain=${SSM_PARAMS_PREFIX}AlisAppDomain \
PrivateChainAwsAccessKey=${SSM_PARAMS_PREFIX}PrivateChainAwsAccessKey \
PrivateChainAwsSecretAccessKey=${SSM_PARAMS_PREFIX}PrivateChainAwsSecretAccessKey \
PrivateChainExecuteApiHost=${SSM_PARAMS_PREFIX}PrivateChainExecuteApiHost \
PrivateChainBridgeAddress=${SSM_PARAMS_PREFIX}PrivateChainBridgeAddress \
PrivateChainAlisTokenAddress=${SSM_PARAMS_PREFIX}PrivateChainAlisTokenAddress \
PrivateChainOperationUrl=${SSM_PARAMS_PREFIX}PrivateChainOperationUrl \
BetaModeFlag=${SSM_PARAMS_PREFIX}BetaModeFlag \
SaltForArticleId=${SSM_PARAMS_PREFIX}SaltForArticleId \
CognitoUserPoolArn=${SSM_PARAMS_PREFIX}CognitoUserPoolArn \
ArticleInfoTableName=${SSM_PARAMS_PREFIX}ArticleInfoTableName \
ArticleContentTableName=${SSM_PARAMS_PREFIX}ArticleContentTableName \
ArticleContentEditHistoryTableName=${SSM_PARAMS_PREFIX}ArticleContentEditHistoryTableName \
ArticleHistoryTableName=${SSM_PARAMS_PREFIX}ArticleHistoryTableName \
ArticleContentEditTableName=${SSM_PARAMS_PREFIX}ArticleContentEditTableName \
ArticleEvaluatedManageTableName=${SSM_PARAMS_PREFIX}ArticleEvaluatedManageTableName \
ArticleAlisTokenTableName=${SSM_PARAMS_PREFIX}ArticleAlisTokenTableName \
ArticleLikedUserTableName=${SSM_PARAMS_PREFIX}ArticleLikedUserTableName \
ArticleFraudUserTableName=${SSM_PARAMS_PREFIX}ArticleFraudUserTableName \
ArticlePvUserTableName=${SSM_PARAMS_PREFIX}ArticlePvUserTableName \
ArticleScoreTableName=${SSM_PARAMS_PREFIX}ArticleScoreTableName \
UsersTableName=${SSM_PARAMS_PREFIX}UsersTableName \
BetaUsersTableName=${SSM_PARAMS_PREFIX}BetaUsersTableName \
UserConfigurationsTableName=${SSM_PARAMS_PREFIX}UserConfigurationsTableName \
ExternalProviderUsersTableName=${SSM_PARAMS_PREFIX}ExternalProviderUsersTableName \
NotificationTableName=${SSM_PARAMS_PREFIX}NotificationTableName \
UnreadNotificationManagerTableName=${SSM_PARAMS_PREFIX}UnreadNotificationManagerTableName \
TopicTableName=${SSM_PARAMS_PREFIX}TopicTableName \
TagTableName=${SSM_PARAMS_PREFIX}TagTableName \
TipTableName=${SSM_PARAMS_PREFIX}TipTableName \
SucceededTipTableName=${SSM_PARAMS_PREFIX}SucceededTipTableName \
NonceTableName=${SSM_PARAMS_PREFIX}NonceTableName \
CommentTableName=${SSM_PARAMS_PREFIX}CommentTableName \
CommentLikedUserTableName=${SSM_PARAMS_PREFIX}CommentLikedUserTableName \
DeletedCommentTableName=${SSM_PARAMS_PREFIX}DeletedCommentTableName \
UserFraudTableName=${SSM_PARAMS_PREFIX}UserFraudTableName \
ScreenedArticleTableName=${SSM_PARAMS_PREFIX}ScreenedArticleTableName \
TokenDistributionTableName=${SSM_PARAMS_PREFIX}TokenDistributionTableName \
UserFirstExperienceTableName=${SSM_PARAMS_PREFIX}UserFirstExperienceTableName \
TokenSendTableName=${SSM_PARAMS_PREFIX}TokenSendTableName \
DistS3BucketName=${SSM_PARAMS_PREFIX}DistS3BucketName \
ElasticSearchEndpoint=${SSM_PARAMS_PREFIX}ElasticSearchEndpoint \
CognitoUserPoolId=${SSM_PARAMS_PREFIX}CognitoUserPoolId \
CognitoUserPoolAppId=${SSM_PARAMS_PREFIX}CognitoUserPoolAppId \
LineChannelId=${SSM_PARAMS_PREFIX}LineChannelId \
LineChannelSecret=${SSM_PARAMS_PREFIX}LineChannelSecret \
ExternalProviderLoginCommonTempPassword=${SSM_PARAMS_PREFIX}ExternalProviderLoginCommonTempPassword \
LineRedirectUri=${SSM_PARAMS_PREFIX}LineRedirectUri \
ExternalProviderLoginMark=${SSM_PARAMS_PREFIX}ExternalProviderLoginMark \
LoginSalt=${SSM_PARAMS_PREFIX}LoginSalt \
TwitterConsumerKey=${SSM_PARAMS_PREFIX}TwitterConsumerKey \
TwitterConsumerSecret=${SSM_PARAMS_PREFIX}TwitterConsumerSecret \
TwitterOauthCallbackUrl=${SSM_PARAMS_PREFIX}TwitterOauthCallbackUrl \
TwitterAppConsumerKey=${SSM_PARAMS_PREFIX}TwitterAppConsumerKey \
TwitterAppConsumerSecret=${SSM_PARAMS_PREFIX}TwitterAppConsumerSecret \
TwitterAppAccessToken=${SSM_PARAMS_PREFIX}TwitterAppAccessToken \
TwitterAppAccessTokenSecret=${SSM_PARAMS_PREFIX}TwitterAppAccessTokenSecret \
YahooClientId=${SSM_PARAMS_PREFIX}YahooClientId \
YahooSecret=${SSM_PARAMS_PREFIX}YahooSecret \
YahooOauthCallbackUrl=${SSM_PARAMS_PREFIX}YahooOauthCallbackUrl \
FacebookAppId=${SSM_PARAMS_PREFIX}FacebookAppId \
FacebookAppSecret=${SSM_PARAMS_PREFIX}FacebookAppSecret \
FacebookOauthCallbackUrl=${SSM_PARAMS_PREFIX}FacebookOauthCallbackUrl \
FacebookAppToken=${SSM_PARAMS_PREFIX}FacebookAppToken \
RestApiArn=${SSM_PARAMS_PREFIX}RestApiArn \
PaidArticlesTableName=${SSM_PARAMS_PREFIX}PaidArticlesTableName \
PaidStatusTableName=${SSM_PARAMS_PREFIX}PaidStatusTableName \
DailyLimitTokenSendValue=${SSM_PARAMS_PREFIX}DailyLimitTokenSendValue \
AuthleteApiKey=${SSM_PARAMS_PREFIX}AuthleteApiKey \
AuthleteApiSecret=${SSM_PARAMS_PREFIX}AuthleteApiSecret \
BurnAddress=${SSM_PARAMS_PREFIX}BurnAddress \
BadgeOperationUrl=${SSM_PARAMS_PREFIX}BadgeOperationUrl \
Web3ServiceBaseUrl=${SSM_PARAMS_PREFIX}Web3ServiceBaseUrl \
AllTokenHistoryCsvDownloadS3Bucket=${SSM_PARAMS_PREFIX}AllTokenHistoryCsvDownloadS3Bucket \
CognitoIdentityPoolId=${SSM_PARAMS_PREFIX}CognitoIdentityPoolId\
AcquisitionInfoTableName=${SSM_PARAMS_PREFIX}AcquisitionInfoTableName \
--capabilities CAPABILITY_IAM \
--no-fail-on-empty-changeset
if [ $1 = "api" ]; then
aws cloudformation package \
--template-file ${target}with-oauth-template.yaml \
--s3-bucket $DEPLOY_BUCKET_NAME \
--output-template-file ${target}with-oauth-package-template.yaml
aws cloudformation deploy \
--template-file ${target}with-oauth-package-template.yaml \
--s3-bucket $DEPLOY_BUCKET_NAME \
--stack-name ${ALIS_APP_ID}${1}-with-oauth \
--parameter-overrides FunctionDeployStackName=${ALIS_APP_ID}${1} \
--capabilities CAPABILITY_IAM
returnCode=$?
if [[ $returnCode = 255 ]]; then
exit 0
fi
fi