Skip to content

Commit

Permalink
fixes in readme, for nodejs
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerwelin committed May 5, 2020
1 parent 6703705 commit 0697829
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
src
apa/
apigw.yml
swagger-api.yml
main
Expand Down
7 changes: 4 additions & 3 deletions tmpl-languages.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ const nodeFunction = `
exports.handler = function(event, context) {
let msg = {
msg: 'hello world'
statusCode: 200,
body: 'hello world'
}
context.succeed(JSON.stringify(msg));
context.succeed(msg);
};
`

const packageJson = `
{
"name": "hello world",
"name": "helloworld",
"version": "1.0.0",
"description": "",
"main": "index.js",
Expand Down
16 changes: 7 additions & 9 deletions tmpl-readme.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,15 @@ $ pip install --user aws-sam-cli
$ sam build --template-file apigw.yml
` + "```" + `
### Package the Project
### Package & Deploy the Project
` + "```" + `bash
$ sam package --template-file apigw.yml --output-template-file out.yaml --s3-bucket {Your-S3-bucket}
$ sam deploy --guided
` + "```" + `
### Deploy the API
` + "```" + `bash
$ aws cloudformation deploy --template-file ./out.yaml --stack-name your-api-project --capabilities CAPABILITY_IAM
` + "```" + `
Go to the AWS console > Cloudformation. Make sure the Cloudformations stack finishes. Take a look at the output to get the URL of your newly created API project. Either curl the address at the /hello endpoint or run the endpoint directly in the API Gateway console.
The --guided flag will set up all needed IAM roles and a S3 bucket and finally will set upp all needed AWS resources and deploy the code.
Check the Outputs from the command line and grab the URL. Now do a curl against URL/helloworld
{{ if and (eq .APIEndpoints "private") }}
However since this is a private api, you need to do the curl from within your VPC
{{ end }}
`
9 changes: 7 additions & 2 deletions tmpl-sam.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ Parameters:
VPCId:
Description: ID of the VPC ID
Type: AWS::EC2::VPC::Id
VPCCidr:
Description: Valid CIDR of the VPC
Type: String
AllowedPattern: ^([0-9]{1,3}\.){3}[0-9]{1,3}(\/([0-9]|[1-2][0-9]|3[0-2]))?$
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x
SubnetIDs:
Description: A list/array of Subnet IDs
Type: List<AWS::EC2::Subnet::Id>
Expand Down Expand Up @@ -46,7 +51,7 @@ Resources:
VpcId: !Ref VPCId
SecurityGroupIngress:
- IpProtocol: tcp
CidrIp: 172.31.190.0/24
CidrIp: !Ref VPCCidr
FromPort: 0
ToPort: 65535
Expand Down Expand Up @@ -130,7 +135,7 @@ Resources:
CodeUri: src/{{ .LambdaFunctionName }}/app/
{{ if and (eq .Language "python")}}Handler: app.handler
Runtime: python3.7{{ end }}{{ if and (eq .Language "ruby")}}Handler: app.handler
Runtime: ruby2.5{{ end }}{{ if and (eq .Language "node")}}Handler: index.js
Runtime: ruby2.5{{ end }}{{ if and (eq .Language "node")}}Handler: index.handler
Runtime: nodejs10.x{{ end }}{{ if and (eq .Language "go")}}Handler: helloworld
Runtime: go1.x{{ end }}{{ if and (eq .Language "java")}}Handler: com.api.HelloWorld
Runtime: java8{{ end }}
Expand Down

0 comments on commit 0697829

Please sign in to comment.