Skip to content

Commit 53daafc

Browse files
committed
more work on SLS workstation, and start of graphql demo
1 parent 7bce30c commit 53daafc

File tree

4 files changed

+114
-3
lines changed

4 files changed

+114
-3
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# AWS
22
Collection of AWS Cloud resources
33

4+
The *cfn-ec2workstation.json* Cloud Formation template will build out a Serverless workstation with NodeJS, NPM, SLS, and REACT frameworks install. You MUST define the parameters **myKeyPair** (name of your SSH Key to access the instance), and optionally **stage** (dev or prod) and **myDomain** (if you have a hosted domain will set a convenience URL *bot-{stage}.{domainname}*)
5+
6+
<code>
7+
aws cloudformation create-stack --stack-name <stackName> --template-body file://cfn-ec2workstation.json --parameters ParameterKey=myKeyPair
8+
</code>
49
## Serverless
510

611
Frameworks with API Gateway/Lambda

cfn-ec2workstation.json

+77-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{ "AWSTemplateFormatVersion" : "2010-09-09",
2-
"Description" : "Template will build SLS workstation",
2+
"Description" : "Template will build SLS workstation, can be used in all stages has SLS and REACT frameworks installed",
33
"Parameters" :
44
{
55
"myKeyPair" : {
66
"Description" : "Amazon EC2 Key Pair",
77
"Type" : "AWS::EC2::KeyPair::KeyName"
88
},
99
"myDomain" : {
10-
"Description" : "Domain to add the sls-${region}",
10+
"Description" : "(optional) Domain to add the sls-${region}",
1111
"Type" : "String",
1212
"Default" : "nodomainname"
1313
}
@@ -24,7 +24,12 @@
2424
"ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" }, "HVM64" ]},
2525
"KeyName" : { "Ref" : "myKeyPair" },
2626
"InstanceType" : "t2.micro",
27-
"Tags" : [ { "Key" : "Role", "Value" : "SLS Workstation" } ],
27+
"IamInstanceProfile" : { "Ref" : "InstanceRole" },
28+
"SecurityGroups" : [ {"Ref" : "SG" } ],
29+
"Tags" : [
30+
{ "Key" : "Name", "Value" : "SLS Workstation" } ,
31+
{ "Key" : "Created", "Value" : "CFN github aws/cgn-ec2workstation.json" }
32+
],
2833
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["",[
2934
"#!/bin/bash", "\n",
3035
"yum update -y", "\n",
@@ -42,6 +47,75 @@
4247
},
4348

4449

50+
51+
52+
53+
"SLSRole": {
54+
"Type" : "AWS::IAM::Role",
55+
"Properties" : {
56+
"AssumeRolePolicyDocument" : {
57+
"Version" : "2012-10-17",
58+
"Statement" : [ {
59+
"Effect" : "Allow",
60+
"Principal" : {
61+
"Service" : [ "ec2.amazonaws.com" ]
62+
},
63+
"Action" : [ "sts:AssumeRole" ]
64+
} ]
65+
},
66+
"Path" : "/",
67+
"Policies" : [
68+
{
69+
"PolicyName" : "sls-iam-instance-policy",
70+
"PolicyDocument": {
71+
"Version" : "2012-10-17",
72+
"Statement" : [
73+
{
74+
"Action" : [
75+
"route53:ChangeResourceRecordSets",
76+
"cloudformation:*"
77+
],
78+
"Resource" : "*",
79+
"Effect" : "Allow"
80+
}
81+
]
82+
}
83+
}
84+
]
85+
}
86+
},
87+
88+
"InstanceRole": {
89+
"Type" : "AWS::IAM::InstanceProfile",
90+
"Properties" : {
91+
"Path" : "/",
92+
"Roles" : [
93+
{ "Ref" : "SLSRole" }
94+
]
95+
}
96+
},
97+
98+
99+
"SG": {
100+
"Type" : "AWS::EC2::SecurityGroup",
101+
"Properties" : {
102+
"GroupDescription" : "SLS Workstation CFN generated group" ,
103+
"SecurityGroupIngress" : [
104+
{ "Description" : "Access to SSH", "IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "0.0.0.0/0" },
105+
{ "Description" : "REACT dev port", "IpProtocol" : "tcp", "FromPort" : "3000", "ToPort" : "3000", "CidrIp" : "0.0.0.0/0" },
106+
{ "Description" : "http test port", "IpProtocol" : "tcp", "FromPort" : "8000", "ToPort" : "8000", "CidrIp" : "0.0.0.0/0" }
107+
],
108+
"Tags" : [
109+
{ "Key" : "Name", "Value" : "SLS Workstation" } ,
110+
{ "Key" : "Created", "Value" : "CFN github aws/cgn-ec2workstation.json" }
111+
]
112+
}
113+
},
114+
115+
116+
117+
118+
45119
"DnsRecord": {
46120
"Type" : "AWS::Route53::RecordSet",
47121
"Condition" : "CreateDnsResources",

garden-gql/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Serverless GraphQL
2+
3+
Attemping to following along with
4+
[Serverless Zone]([200~https://serverless.zone/graphql-with-the-serverless-framework-79924829a8ca)
5+
6+

garden-gql/serverless.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
service: garden-gql
2+
provider:
3+
name: aws
4+
runtime: nodejs4.3
5+
region: us-west-2
6+
7+
iamRoleStatements:
8+
- Effect: Allow
9+
Action:
10+
- dynamodb:DescribeTable
11+
- dynamodb:Query
12+
- dynamodb:Scan
13+
- dynamodb:GetItem
14+
- dynamodb:PutItem
15+
- dynamodb:UpdateItem
16+
- dynamodb:DeleteItem
17+
Resource: "arn:aws:dynamodb:us-west-2:*:*"
18+
19+
functions:
20+
graphQl:
21+
handler: index.graphql
22+
events:
23+
- http:
24+
path: graphql
25+
method: post
26+
cors: true

0 commit comments

Comments
 (0)