-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy_lex_bot.sh
154 lines (144 loc) · 4.85 KB
/
deploy_lex_bot.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
while getopts "ha:" opt; do
case $opt in
h) echo -e $USAGE && exit
;;
a) AWSACCT="$OPTARG"
;;
\?) echo "Invalid option -$OPTARG" >&2 && exit
;;
esac
done
if [[ -z $AWSACCT ]]; then
echo "Must provide an account for Lambda association, -a option... $AWSACCT"
exit
fi
function prep_build {
echo "Prep AWS Lex build..."
mkdir -p ./_build_lex
cp lex/full-configuration/*.json _build_lex/
}
function swap_in_account_number {
echo "Using account number: $AWSACCT"
sed -i -e "s/REPLACE_ME_ACCT/$AWSACCT/g" _build_lex/*.json
}
function add_lambda_policies {
echo "Adding lambda policy 2 for set_office_hours..."
aws lambda add-permission \
--region us-east-1 \
--function-name set_office_hours \
--statement-id 2 \
--principal lex.amazonaws.com \
--action lambda:InvokeFunction \
--source-arn arn:aws:lex:us-east-1:${AWSACCT}:intent:AddDiscusionTopicOfficeHours:*
echo "Adding lambda policy 3 for set_office_hours..."
aws lambda add-permission \
--region us-east-1 \
--function-name set_office_hours \
--statement-id 3 \
--principal lex.amazonaws.com \
--action lambda:InvokeFunction \
--source-arn arn:aws:lex:us-east-1:${AWSACCT}:intent:SetTodaysOfficeHours:*
echo "Adding lambda policy 1 for add_discussion_topic..."
aws lambda add-permission \
--region us-east-1 \
--function-name add_discussion_topic \
--statement-id 1 \
--principal lex.amazonaws.com \
--action lambda:InvokeFunction \
--source-arn arn:aws:lex:us-east-1:${AWSACCT}:intent:AddDiscusionTopicOfficeHours:*
echo "Adding lambda policy 1 for get_office_hours..."
aws lambda add-permission \
--region us-east-1 \
--function-name get_office_hours \
--statement-id 1 \
--principal lex.amazonaws.com \
--action lambda:InvokeFunction \
--source-arn arn:aws:lex:us-east-1:${AWSACCT}:intent:AddDiscusionTopicOfficeHours:*
echo "Adding lambda policy 2 for get_office_hours..."
aws lambda add-permission \
--region us-east-1 \
--function-name get_office_hours \
--statement-id 2 \
--principal lex.amazonaws.com \
--action lambda:InvokeFunction \
--source-arn arn:aws:lex:us-east-1:${AWSACCT}:intent:GetTeamsOfficeHours:*
echo "Adding lambda policy 1 for lookup_discussion_topics..."
aws lambda add-permission \
--region us-east-1 \
--function-name lookup_discussion_topics \
--statement-id 1 \
--principal lex.amazonaws.com \
--action lambda:InvokeFunction \
--source-arn arn:aws:lex:us-east-1:${AWSACCT}:intent:AddDiscusionTopicOfficeHours:*
echo "Adding lambda policy 2 for lookup_discussion_topics..."
aws lambda add-permission \
--region us-east-1 \
--function-name lookup_discussion_topics \
--statement-id 2 \
--principal lex.amazonaws.com \
--action lambda:InvokeFunction \
--source-arn arn:aws:lex:us-east-1:${AWSACCT}:intent:LookupDiscussionTopics:*
}
function put_slots {
echo "Deploying slot GetDiscussionTopic..."
aws lex-models put-slot-type \
--name GetDiscussionTopic \
--cli-input-json file://_build_lex/put-slot-type-GetDiscussionTopic.json \
--region us-east-1 \
--checksum ""
echo "Deploying slot OfficeHoursLocation..."
aws lex-models put-slot-type \
--name OfficeHoursLocation \
--cli-input-json file://_build_lex/put-slot-type-OfficeHoursLocation.json \
--region us-east-1 \
--checksum ""
echo "Deploying slot SetTeam..."
aws lex-models put-slot-type \
--name SetTeam \
--cli-input-json file://_build_lex/put-slot-type-SetTeam.json \
--region us-east-1 \
--checksum ""
}
function put_intents {
echo "Deploying intent AddDiscussionTopicOfficeHours..."
aws lex-models put-intent \
--name AddDiscusionTopicOfficeHours \
--cli-input-json file://_build_lex/put-intent-AddDiscussionTopicOfficeHours.json \
--region us-east-1 \
--checksum ""
echo "Deploying intent GetTeamsOfficeHours..."
aws lex-models put-intent \
--name GetTeamsOfficeHours \
--cli-input-json file://_build_lex/put-intent-GetTeamsOfficeHours.json \
--region us-east-1 \
--checksum ""
echo "Deploying intent LookUpDiscussionTopic..."
aws lex-models put-intent \
--name LookupDiscussionTopics \
--cli-input-json file://_build_lex/put-intent-LookupDiscussionTopic.json \
--region us-east-1 \
--checksum ""
echo "Deploying intent SetTodaysOfficeHours..."
aws lex-models put-intent \
--name SetTodaysOfficeHours \
--cli-input-json file://_build_lex/put-intent-SetTodaysOfficeHours.json \
--region us-east-1 \
--checksum ""
}
function put_bot {
aws lex-models put-bot \
--name OfficeHoursBot \
--cli-input-json file://_build_lex/put-bot.json \
--region us-east-1 \
--checksum ""
}
function main {
#add_lambda_policies
prep_build
swap_in_account_number
put_slots
put_intents
put_bot
}
main