Skip to content

Commit 4c5142d

Browse files
committed
docs: 📝 update resources and documentation accordingly
1 parent 86b238e commit 4c5142d

2 files changed

Lines changed: 64 additions & 7 deletions

File tree

fargate-eventbridge-serverless/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Important: this application uses various AWS services and there are costs associ
1111
* [Git CLI](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) installed
1212
* [NodeJS](https://nodejs.org/en/download/) (LTS version) installed
1313
* [Serverless Framework CLI](https://www.serverless.com/framework/docs/getting-started) installed
14+
* [Docker Desktop](https://docs.docker.com/desktop/) installed
1415

1516
## Deployment Instructions
1617

@@ -26,7 +27,7 @@ Important: this application uses various AWS services and there are costs associ
2627
cd serverless-patterns/fargate-eventbridge-serverless
2728
```
2829

29-
1. Replace the subnet and security group ids in serverless.yml file to your default ids.
30+
1. Open Docker Desktop and keep it running in the background.
3031

3132
1. From the command line, use Serverless Framework to deploy the AWS resources for the pattern as specified in the serverless.yml file:
3233

@@ -42,13 +43,15 @@ Important: this application uses various AWS services and there are costs associ
4243

4344
## How it works
4445

45-
- The image is constructed directly from the Dockerfile that is provided.
46+
- Make sure you have all the things configured mentioned in Requirements section.
47+
- The image is constructed directly from the Dockerfile that is provided using Docker Desktop.
4648
- The image is pushed to Amazon Elastic Container Repository (ECR).
4749
- Fargate Task role is created.
4850
- Fargate Execution role is created.
4951
- The S3 bucket for output is created.
5052
- The ECS cluster is created.
5153
- The Task Definition is created. This also passes the environment variable to the scheduled task.
54+
- Networking resources are created.
5255
- Finally EventBridge Rule is created for running task every 10th minute of the hour.
5356

5457
## Testing
@@ -61,7 +64,6 @@ To test the deployment, you can verify by going to the output S3 bucket and find
6164
}
6265
```
6366

64-
6567
## Cleanup
6668

6769
1. Empty the output S3 bucket.

fargate-eventbridge-serverless/serverless.yml

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ fargate:
2727
vpc:
2828
assignPublicIp: true
2929
securityGroupIds:
30-
- sg-1234
30+
- {Ref: SecurityGroup}
3131
subnetIds:
32-
- subnet-1234
32+
- {Ref: Subnet}
3333
iamRoleStatements:
3434
- Effect: Allow
3535
Action:
@@ -43,9 +43,9 @@ fargate:
4343
vpc:
4444
assignPublicIp: true
4545
securityGroupIds:
46-
- sg-1234
46+
- {Ref: SecurityGroup}
4747
subnetIds:
48-
- subnet-1234
48+
- {Ref: Subnet}
4949
memory: '0.5GB'
5050
cpu: 256
5151
schedule: cron(0/10 * * * ? *)
@@ -58,6 +58,61 @@ resources:
5858
Type: AWS::S3::Bucket
5959
Properties:
6060
BucketName: ${self:custom.destinationBucket}
61+
# creates a VPC with a public subnets within the VPC
62+
VPC:
63+
Type: AWS::EC2::VPC
64+
Properties:
65+
CidrBlock: 12.2.1.0/24
66+
EnableDnsHostnames: true
67+
EnableDnsSupport: true
68+
Subnet:
69+
Type: AWS::EC2::Subnet
70+
Properties:
71+
VpcId: { Ref: VPC }
72+
CidrBlock: 12.2.1.0/25
73+
MapPublicIpOnLaunch: true
74+
AvailabilityZone: !Select
75+
- 0
76+
- Fn::GetAZs: {Ref: 'AWS::Region'}
77+
SecurityGroup:
78+
Type: AWS::EC2::SecurityGroup
79+
Properties:
80+
GroupDescription: SG created via serverless framework
81+
VpcId: { Ref: VPC }
82+
SecurityGroupIngress:
83+
- IpProtocol: tcp
84+
FromPort: 80
85+
ToPort: 80
86+
CidrIp: 0.0.0.0/0
87+
- IpProtocol: tcp
88+
FromPort: 443
89+
ToPort: 443
90+
CidrIp: 0.0.0.0/0
91+
# internet gateway that connects the vpc to the internet
92+
InternetGateway:
93+
Type: AWS::EC2::InternetGateway
94+
AttachGateway:
95+
Type: AWS::EC2::VPCGatewayAttachment
96+
Properties:
97+
VpcId: { Ref: VPC }
98+
InternetGatewayId: { Ref: InternetGateway }
99+
PublicSubnetRouteTable:
100+
Type: AWS::EC2::RouteTable
101+
Properties:
102+
VpcId: { Ref: VPC }
103+
# creates public routes for the subnet
104+
PublicSubnetRoute:
105+
Type: AWS::EC2::Route
106+
DependsOn: AttachGateway
107+
Properties:
108+
RouteTableId: { Ref: PublicSubnetRouteTable }
109+
DestinationCidrBlock: 0.0.0.0/0
110+
GatewayId: { Ref: InternetGateway }
111+
PublicSubnetRouteTableAssociationOne:
112+
Type: AWS::EC2::SubnetRouteTableAssociation
113+
Properties:
114+
RouteTableId: { Ref: PublicSubnetRouteTable }
115+
SubnetId: { Ref: Subnet }
61116

62117
plugins:
63118
- serverless-fargate

0 commit comments

Comments
 (0)