From 6143bf05b78bb919719bd8922c7750b7f557f9fb Mon Sep 17 00:00:00 2001 From: karannnn-exe <67971144+karannnn-exe@users.noreply.github.com> Date: Sat, 3 Apr 2021 13:49:31 +0530 Subject: [PATCH 1/3] Create Dockerfile --- Dockerfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..3542ad7a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM node + +WORKDIR /usr/src/app + +COPY package*.json ./ + +RUN npm install --verbose + +COPY . . + +EXPOSE 3000 + +CMD ["npm","start"] From 4dd89cece95d15cb9b9705984da895921a92e25c Mon Sep 17 00:00:00 2001 From: karannnn-exe <67971144+karannnn-exe@users.noreply.github.com> Date: Sun, 4 Apr 2021 22:32:41 +0530 Subject: [PATCH 2/3] Add files via upload --- cf.yml | 192 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 cf.yml diff --git a/cf.yml b/cf.yml new file mode 100644 index 00000000..8088618e --- /dev/null +++ b/cf.yml @@ -0,0 +1,192 @@ +Parameters: + VpcId: + Type: AWS::EC2::VPC::Id + Description: Select a VPC that allows instances access to the Internet. + + SubnetId: + Type: List + Description: Select at least two subnets in your selected VPC. + +Resources: + ECSCluster: + Type: AWS::ECS::Cluster + + EcsSecurityGroup: + Type: AWS::EC2::SecurityGroup + Properties: + GroupDescription: ECS Security Group + VpcId: !Ref 'VpcId' + + EcsSecurityGroupHTTPinbound: + Type: AWS::EC2::SecurityGroupIngress + Properties: + GroupId: !Ref 'EcsSecurityGroup' + IpProtocol: tcp + FromPort: '80' + ToPort: '80' + CidrIp: 0.0.0.0/0 + + EcsSecurityGroupSSHinbound: + Type: AWS::EC2::SecurityGroupIngress + Properties: + GroupId: !Ref 'EcsSecurityGroup' + IpProtocol: tcp + FromPort: '22' + ToPort: '22' + CidrIp: 0.0.0.0/0 +# /------------------------------------------------------------------- + EcsSecurityGroupALBports: + Type: AWS::EC2::SecurityGroupIngress + Properties: + GroupId: !Ref 'EcsSecurityGroup' + IpProtocol: tcp + FromPort: '31000' + ToPort: '61000' + SourceSecurityGroupId: !Ref 'EcsSecurityGroup' +# /-------------------------------------------------------------------- + + taskdefinition: + Type: AWS::ECS::TaskDefinition + Properties: + # family name + Family: !Join ['', [!Ref 'AWS::StackName', -ecs-react-demo-app]] + ContainerDefinitions: + - Name: react-app + Cpu: '50' + Essential: 'true' + Image: 042870386288.dkr.ecr.us-west-2.amazonaws.com/mytask1repo:latest + Memory: '300' + PortMappings: + - ContainerPort: 3000 + + ECSALB: + Type: AWS::ElasticLoadBalancingV2::LoadBalancer + Properties: + Name: ECSALB + Scheme: internet-facing + # LoadBalancerAttributes: + # - Key: idle_timeout.timeout_seconds + # Value: '30' + Subnets: !Ref 'SubnetId' + SecurityGroups: [!Ref 'EcsSecurityGroup'] + + ALBListener: + Type: AWS::ElasticLoadBalancingV2::Listener + DependsOn: ECSServiceRole + Properties: + DefaultActions: + - Type: forward + TargetGroupArn: !Ref 'ECSTG' + LoadBalancerArn: !Ref 'ECSALB' + Port: '80' + Protocol: HTTP + + ECSALBListenerRule: + Type: AWS::ElasticLoadBalancingV2::ListenerRule + DependsOn: ALBListener + Properties: + Actions: + - Type: forward + TargetGroupArn: !Ref 'ECSTG' + Conditions: + - Field: path-pattern + Values: [/] + ListenerArn: !Ref 'ALBListener' + Priority: 1 + + ECSTG: + Type: AWS::ElasticLoadBalancingV2::TargetGroup + DependsOn: ECSALB + Properties: + HealthCheckIntervalSeconds: 30 + HealthCheckPath: / + HealthCheckProtocol: HTTP + HealthCheckTimeoutSeconds: 5 + HealthyThresholdCount: 2 + Name: ECSTG + Port: 80 + Protocol: HTTP + UnhealthyThresholdCount: 2 + VpcId: !Ref 'VpcId' + + ECSAutoScalingGroup: + Type: AWS::AutoScaling::AutoScalingGroup + Properties: + VPCZoneIdentifier: !Ref 'SubnetId' + LaunchConfigurationName: !Ref 'ContainerInstances' + MinSize: '1' + MaxSize: '2' + DesiredCapacity: '1' + UpdatePolicy: + AutoScalingReplacingUpdate: + WillReplace: 'true' + + ContainerInstances: + Type: AWS::AutoScaling::LaunchConfiguration + Properties: + ImageId: ami-017a715104f93ea81 + SecurityGroups: [!Ref 'EcsSecurityGroup'] + InstanceType: t2.micro + IamInstanceProfile: !Ref 'EC2InstanceProfile' + UserData: + Fn::Base64: !Sub | + #!/bin/bash -xe + echo ECS_CLUSTER=${ECSCluster} >> /etc/ecs/ecs.config + + service: + Type: AWS::ECS::Service + DependsOn: ALBListener + Properties: + Cluster: !Ref 'ECSCluster' + DesiredCount: '1' + LoadBalancers: + - ContainerName: react-app + ContainerPort: '3000' + TargetGroupArn: !Ref 'ECSTG' + Role: !Ref 'ECSServiceRole' + TaskDefinition: !Ref 'taskdefinition' + + ECSServiceRole: + Type: AWS::IAM::Role + Properties: + AssumeRolePolicyDocument: + Statement: + - Effect: Allow + Principal: + Service: [ecs.amazonaws.com] + Action: ['sts:AssumeRole'] + Path: / + Policies: + - PolicyName: ecs-service + PolicyDocument: + Statement: + - Effect: Allow + Action: ['elasticloadbalancing:DeregisterInstancesFromLoadBalancer', 'elasticloadbalancing:DeregisterTargets', + 'elasticloadbalancing:Describe*', 'elasticloadbalancing:RegisterInstancesWithLoadBalancer', + 'elasticloadbalancing:RegisterTargets', 'ec2:Describe*', 'ec2:AuthorizeSecurityGroupIngress'] + Resource: '*' + EC2Role: + Type: AWS::IAM::Role + Properties: + AssumeRolePolicyDocument: + Statement: + - Effect: Allow + Principal: + Service: [ec2.amazonaws.com] + Action: ['sts:AssumeRole'] + Path: / + Policies: + - PolicyName: ecs-service + PolicyDocument: + Statement: + - Effect: Allow + Action: ['ecs:CreateCluster', 'ecs:DeregisterContainerInstance', 'ecs:DiscoverPollEndpoint', + 'ecs:Poll', 'ecs:RegisterContainerInstance', 'ecs:StartTelemetrySession', + 'ecs:Submit*', 'logs:CreateLogStream', 'logs:PutLogEvents',ecr:*] + Resource: '*' + EC2InstanceProfile: + Type: AWS::IAM::InstanceProfile + Properties: + Path: / + Roles: [!Ref 'EC2Role'] + From f3f0ebde2d951ec986a13d9dd32f60f336bf5870 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 16 Aug 2021 10:19:35 +0000 Subject: [PATCH 3/3] 1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a4d48ce3..f92cc29a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Simple React JS Project +# iiiiiiSimple React JS Project ## What is the use of this Repo