-
Notifications
You must be signed in to change notification settings - Fork 14
/
setup.sh
executable file
·41 lines (34 loc) · 1.07 KB
/
setup.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
#!/bin/bash
. set_env_vars.sh $1
# Enable Services
SERVICES=(
cloudiot
pubsub
)
for svc in ${SERVICES[@]};
do
printf "Enabling Service: ${svc}\n"
gcloud services enable ${svc}.googleapis.com
done
# Create pubsub topics for events and state
gcloud pubsub topics create $PUBSUB_TOPIC_EVENTS
gcloud pubsub subscriptions create $PUBSUB_TOPIC_EVENTS-sub --topic=$PUBSUB_TOPIC_EVENTS --topic-project=$GCLOUD_PROJECT
gcloud pubsub topics create $PUBSUB_TOPIC_STATE
gcloud pubsub subscriptions create $PUBSUB_TOPIC_STATE-sub --topic=$PUBSUB_TOPIC_STATE --topic-project=$GCLOUD_PROJECT
gcloud iot registries create $REGISTRY \
--region=$LOCATION
--event-notification-config=topic=$PUBSUB_TOPIC_EVENTS \
--state-pubsub-topic=$PUBSUB_TOPIC_STATE
# Create gateway
if [ ! -f ./ec_public.pem ]; then
./generate_key_pair.sh
else
echo "Certificates already exists."
fi
gcloud beta iot devices create $GATEWAY_ID \
--device-type=gateway \
--region=$LOCATION \
--registry=$REGISTRY \
--project=$GCLOUD_PROJECT \
--public-key path=ec_public.pem,type=es256-pem \
--auth-method=ASSOCIATION_ONLY