Skip to content

Commit 8bac82e

Browse files
committed
Required changes for new location of CSO API and app.
1 parent c839919 commit 8bac82e

File tree

4 files changed

+39
-39
lines changed

4 files changed

+39
-39
lines changed

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "cso-api-next",
2+
"name": "cso-production",
33
"version": "1.0.0",
44
"main": "index.js",
5-
"repository": "https://github.com/jonahjoughin/cso-api-next.git",
5+
"repository": ""https://github.com/communitysnowobs/cso-api,
66
"author": "Jonah Joughin <[email protected]>",
77
"license": "MIT",
88
"scripts": {
@@ -18,5 +18,6 @@
1818
"request": "^2.88.2",
1919
"request-promise": "^4.2.5",
2020
"xml2js": "^0.4.19"
21-
}
21+
},
22+
"description": "The CSO API in MountainHub's account"
2223
}

scripts/deploy.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@ ENVIRONMENT_JSON='
1313
}
1414
}'
1515

16-
aws --profile cso lambda update-function-code \
16+
aws --profile mountainhub-cso lambda update-function-code \
1717
--function-name observations \
1818
--zip-file fileb://builds/observations/index.zip
1919

20-
aws --profile cso lambda update-function-configuration \
20+
aws --profile mountainhub-cso lambda update-function-configuration \
2121
--function-name observations \
2222
--environment "$ENVIRONMENT_JSON"
2323

24-
aws --profile cso lambda update-function-code \
24+
aws --profile mountainhub-cso lambda update-function-code \
2525
--function-name snapshot \
2626
--zip-file fileb://builds/snapshot/index.zip
2727

28-
aws --profile cso lambda update-function-configuration \
28+
aws --profile mountainhub-cso lambda update-function-configuration \
2929
--function-name snapshot \
3030
--environment "$ENVIRONMENT_JSON"
3131

32-
aws --profile cso lambda update-function-code \
32+
aws --profile mountainhub-cso lambda update-function-code \
3333
--function-name import \
3434
--zip-file fileb://builds/import/index.zip
3535

36-
aws --profile cso lambda update-function-configuration \
36+
aws --profile mountainhub-cso lambda update-function-configuration \
3737
--function-name import \
3838
--environment "$ENVIRONMENT_JSON"

scripts/init.sh

+25-25
Original file line numberDiff line numberDiff line change
@@ -14,98 +14,98 @@ ENVIRONMENT_JSON='
1414
}'
1515

1616
# Delete existing functions
17-
aws --profile cso lambda delete-function --function-name observations
18-
aws --profile cso lambda delete-function --function-name snapshot
19-
aws --profile cso lambda delete-function --function-name import
17+
aws --profile mountainhub-cso lambda delete-function --function-name observations
18+
aws --profile mountainhub-cso lambda delete-function --function-name snapshot
19+
aws --profile mountainhub-cso lambda delete-function --function-name import
2020

2121
# Create new functions
22-
aws --profile cso lambda create-function \
22+
aws --profile mountainhub-cso lambda create-function \
2323
--function-name observations \
2424
--runtime nodejs12.x \
2525
--handler index.handler \
26-
--role arn:aws:iam::105987315436:role/lambda-cli-role \
26+
--role arn:aws:iam::161987410525:role/lambda-cli-role \
2727
--zip-file fileb://builds/observations/index.zip \
2828
--timeout 60 \
2929
--memory-size 256 \
3030
--environment "$ENVIRONMENT_JSON"
3131

32-
aws --profile cso lambda create-function \
32+
aws --profile mountainhub-cso lambda create-function \
3333
--function-name snapshot \
3434
--runtime nodejs12.x \
3535
--handler index.handler \
36-
--role arn:aws:iam::105987315436:role/lambda-cli-role \
36+
--role arn:aws:iam::161987410525:role/lambda-cli-role \
3737
--zip-file fileb://builds/snapshot/index.zip \
3838
--timeout 120 \
3939
--memory-size 1024 \
4040
--environment "$ENVIRONMENT_JSON"
4141

42-
aws --profile cso lambda create-function \
42+
aws --profile mountainhub-cso lambda create-function \
4343
--function-name import \
4444
--runtime nodejs12.x \
4545
--handler index.handler \
46-
--role arn:aws:iam::105987315436:role/lambda-cli-role \
46+
--role arn:aws:iam::161987410525:role/lambda-cli-role \
4747
--zip-file fileb://builds/import/index.zip \
4848
--timeout 120 \
4949
--memory-size 1024 \
5050
--environment "$ENVIRONMENT_JSON"
5151

5252
# Get ARNS for scheduled events
53-
snapshot_arn=$(aws --profile cso events put-rule \
53+
snapshot_arn=$(aws --profile mountainhub-cso events put-rule \
5454
--name snapshot \
5555
--schedule-expression 'rate(1 hour)' | jq -r ".RuleArn")
5656

57-
import_arn=$(aws --profile cso events put-rule \
57+
import_arn=$(aws --profile mountainhub-cso events put-rule \
5858
--name import \
5959
--schedule-expression 'rate(15 minutes)' | jq -r ".RuleArn")
6060

6161
# Remove existing scheduling permissions
62-
aws --profile cso lambda remove-permission --function-name observations --statement-id observations
63-
aws --profile cso lambda remove-permission --function-name snapshot --statement-id snapshot
64-
aws --profile cso lambda remove-permission --function-name import --statement-id import
62+
aws --profile mountainhub-cso lambda remove-permission --function-name observations --statement-id observations
63+
aws --profile mountainhub-cso lambda remove-permission --function-name snapshot --statement-id snapshot
64+
aws --profile mountainhub-cso lambda remove-permission --function-name import --statement-id import
6565

6666
# Create new scheduling permissions
67-
snapshot_function_arn=$(aws --profile cso lambda add-permission \
67+
snapshot_function_arn=$(aws --profile mountainhub-cso lambda add-permission \
6868
--function-name snapshot \
6969
--statement-id snapshot \
7070
--action 'lambda:InvokeFunction' \
7171
--principal events.amazonaws.com \
7272
--source-arn $snapshot_arn | jq -r ".Statement" | jq -r ".Resource")
7373

74-
import_function_arn=$(aws --profile cso lambda add-permission \
74+
import_function_arn=$(aws --profile mountainhub-cso lambda add-permission \
7575
--function-name import \
7676
--statement-id import \
7777
--action 'lambda:InvokeFunction' \
7878
--principal events.amazonaws.com \
7979
--source-arn $import_arn | jq -r ".Statement" | jq -r ".Resource")
8080

8181
# Create new schedulers
82-
aws --profile cso events put-targets --rule snapshot --targets "Id"="1","Arn"="$snapshot_function_arn"
83-
aws --profile cso events put-targets --rule import --targets "Id"="1","Arn"="$import_function_arn"
82+
aws --profile mountainhub-cso events put-targets --rule snapshot --targets "Id"="1","Arn"="$snapshot_function_arn"
83+
aws --profile mountainhub-cso events put-targets --rule import --targets "Id"="1","Arn"="$import_function_arn"
8484

85-
API_GATEWAY_ID=r21887apdb
86-
API_PARENT_ID=$(aws --profile cso apigateway get-resources --rest-api-id $API_GATEWAY_ID | jq -r '.items[] | select(.path == "/") | .id')
85+
API_GATEWAY_ID=98r2uqb5v6
86+
API_PARENT_ID=$(aws --profile mountainhub-cso apigateway get-resources --rest-api-id $API_GATEWAY_ID | jq -r '.items[] | select(.path == "/") | .id')
8787
REGION="us-west-2"
88-
ACCOUNT="105987315436"
88+
ACCOUNT="161987410525"
8989

90-
API_RESOURCE_ID=$(aws --profile cso apigateway create-resource --rest-api-id $API_GATEWAY_ID \
90+
API_RESOURCE_ID=$(aws --profile mountainhub-cso apigateway create-resource --rest-api-id $API_GATEWAY_ID \
9191
--path-part observations \
9292
--parent-id $API_PARENT_ID | jq -r ".id")
9393

94-
aws --profile cso apigateway put-method \
94+
aws --profile mountainhub-cso apigateway put-method \
9595
--rest-api-id $API_GATEWAY_ID \
9696
--resource-id $API_RESOURCE_ID \
9797
--http-method ANY \
9898
--authorization-type NONE
9999

100-
aws --profile cso apigateway put-integration \
100+
aws --profile mountainhub-cso apigateway put-integration \
101101
--rest-api-id $API_GATEWAY_ID \
102102
--resource-id $API_RESOURCE_ID \
103103
--http-method ANY \
104104
--type AWS_PROXY \
105105
--integration-http-method POST \
106106
--uri arn:aws:apigateway:"$REGION":lambda:path/2015-03-31/functions/arn:aws:lambda:"$REGION":"$ACCOUNT":function:observations/invocations
107107

108-
aws --profile cso lambda add-permission \
108+
aws --profile mountainhub-cso lambda add-permission \
109109
--function-name observations \
110110
--statement-id observations \
111111
--action 'lambda:InvokeFunction' \

src/snapshot/index.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ const AWS = require('aws-sdk');
33

44
// Snapshot configurations
55
const configs = [
6-
{ name: "data.csv", params: { format: "csv", bucket: "cso-app" }},
7-
{ name: "data.geojson", params: { format: "geojson", providers: "mountainhub,snowpilot,regobs", bucket: "cso-app"}},
8-
{ name: "data.geojson", params: { format: "geojson", providers: "mountainhub,snowpilot,regobs", bucket: "cso-app-beta"}},
9-
{ name: "data.json", params: { format: "json", bucket: "cso-app" }}
6+
{ name: "data.csv", params: { format: "csv", bucket: "cso-app-mtn-hub" }},
7+
{ name: "data.geojson", params: { format: "geojson", providers: "mountainhub,snowpilot,regobs", bucket: "cso-app-mtn-hub"}},
8+
{ name: "data.json", params: { format: "json", bucket: "cso-app-mtn-hub" }}
109
]
1110

1211
const snapshot = async (templates) => {
@@ -30,4 +29,4 @@ exports.handler = async (event, context) => {
3029
})
3130
)
3231
);
33-
}
32+
}

0 commit comments

Comments
 (0)