open311-services

module
v0.0.0-...-9fc93d6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2023 License: Apache-2.0

README

Open311 Services

This repos contains the back end implementation of the Social Torch Open311 Services. The YAML file specifies the AWS cloud formation template, which spins up the necessary infrastructure to use API Gateway, Cognito, S3 buckets, DynamoDB, and corresponding lambda functions.

See this nice blog by Alex Edwards for more details on hooking up the AWS bits: How to build a Serverless API with Go and AWS Lambda

Get Started

$ > mkdir -p $GOPATH/src/github.com/social-torch
$ > cd  $GOPATH/src/github.com/social-torch
$ > git clone git@github.com:social-torch/open311-services

Dependencies

$ > go get github.com/aws/aws-lambda-go/events
$ > go get github.com/aws/aws-lambda-go/lambda
$ > go get github.com/stretchr/testify/assert
$ > sudo yum install jq

Also depends on docker, the AWS CLI and the AWS SAM CLI

Build

# Build binary
$ > make build

Test

# Test Go Code
$ > make test

AWS provides SAM Local to run serverless applications locally for quick development and testing.

# Start a local, containerized instantiation of endpoints and lambda functions
$ > make run

Deploy to Cloud

Ensure your AWS credentials are set up properly for the account to which you wish to deploy.

Create .env
AWS_ACCOUNT_ID=1234567890
AWS_BUCKET_NAME=your-bucket-name-for-cloudformation-package-data
AWS_REGION=us-west-1
AWS_STACK_NAME=your-cloudformation-stack-name
AWS_STAGE=Prod
AWS_USER_POOL=your-cognito-pool-ARN
AWS_IMAGE_BUCKET_NAME=name-of-bucket-to-store-mobile-image-uploads
Command
# Create S3 Bucket
$ > make configure

# Upload data to S3 Bucket
$ > make package

# Deploy CloudFormation Stack
$ > make deploy

Usage

$ > make outputs

[
  {
    "OutputKey": "URL",
    "OutputValue": "https://random-id.execute-api.us-west-1.amazonaws.com/Prod",
    "Description": "URL for HTTPS Endpoint"
  }
]

$ > curl https://random-id.execute-api.us-west-1.amazonaws.com/Stage/services

TODO:  Show all calls

$ > curl https://random-id.execute-api.us-west-1.amazonaws.com/Stage/requests

TODO:  Show all calls

Security Note

Until we automate it in the YAML, you must manually add a security policy for the CitiesRole, RequestRole, UsersRole and ServicesRole to access DynamoDB. You must also attach a policy for the ImagesRole to access the appropriate S3 images bucket.

When accessing the cloud API, your request will need an authorization token.

Directories

Path Synopsis
handler
cities command
images command
request command
service command
user command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL