From c9da7daa28fa1cc76800597bcdb1019a369b9bb9 Mon Sep 17 00:00:00 2001 From: yoppytaro Date: Sun, 12 Nov 2023 07:39:23 +0900 Subject: [PATCH] =?UTF-8?q?#4=20=E3=83=9E=E3=83=AB=E3=83=81AZ=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C=E3=81=97=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=83=95=E3=83=A9=E3=82=92=E6=A7=8B=E7=AF=89=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cloudformation-v2/main.yml | 114 ++++++++ cloudformation-v2/output/.gitignore | 1 + cloudformation-v2/stacks/cloudwatch.yml | 35 +++ cloudformation-v2/stacks/ecs.yml | 111 ++++++++ cloudformation-v2/stacks/iam-role.yml | 38 +++ cloudformation-v2/stacks/rds.yml | 95 +++++++ cloudformation-v2/stacks/vpc.yml | 334 ++++++++++++++++++++++++ docker/base/nginx/entrypoint.sh | 13 - tools/util.sh | 12 + 9 files changed, 740 insertions(+), 13 deletions(-) create mode 100644 cloudformation-v2/main.yml create mode 100644 cloudformation-v2/output/.gitignore create mode 100644 cloudformation-v2/stacks/cloudwatch.yml create mode 100644 cloudformation-v2/stacks/ecs.yml create mode 100644 cloudformation-v2/stacks/iam-role.yml create mode 100644 cloudformation-v2/stacks/rds.yml create mode 100644 cloudformation-v2/stacks/vpc.yml diff --git a/cloudformation-v2/main.yml b/cloudformation-v2/main.yml new file mode 100644 index 0000000..bfdb028 --- /dev/null +++ b/cloudformation-v2/main.yml @@ -0,0 +1,114 @@ +# ------------------------------------------------------------# +# Create Resource +# ------------------------------------------------------------# +AWSTemplateFormatVersion: "2010-09-09" +Description: + Laravel on ECS + +Metadata: + "AWS::CloudFormation::Interface": + ParameterGroups: + - Label: + default: "Project Name Prefix" + Parameters: + - PJPrefix + - Label: + default: VPC + Parameters: + - VPCCIDR + - Label: + default: PublicSubnet + Parameters: + - PublicSubnet1CIDR + - Label: + default: PrivateSubnet + Parameters: + - PrivateSubnet1CIDR + +Parameters: + PJPrefix: + Type: String + Default: laravel-template + ConstraintDescription: Invalid input value for the PJPrefix. + + VPCCIDR: + Type: String + Default: 10.0.0.0/16 + MinLength: 9 + MaxLength: 18 + AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2}) + ConstraintDescription: must be a valid VPCCidrBlock. + + PublicSubnet1CIDR: + Type: String + Default: 10.0.10.0/24 + MinLength: 9 + MaxLength: 18 + AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2}) + ConstraintDescription: must be a valid PublicSubnet1CidrBlock. + + PrivateSubnet1CIDR: + Type: String + Default: 10.0.20.0/24 + MinLength: 9 + MaxLength: 18 + AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2}) + ConstraintDescription: must be a valid PrivateSubnet1CidrBlock. + + PrivateSubnet2CIDR: + Type: String + Default: 10.0.21.0/24 + MinLength: 9 + MaxLength: 18 + AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2}) + ConstraintDescription: must be a valid PrivateSubnet2CidrBlock. + +Resources: + # ------------ IAM Role ---------------- + iamRole: + Type : AWS::CloudFormation::Stack + Properties: + Parameters: + PJPrefix : !Ref PJPrefix + TemplateURL: ./stacks/iam-role.yml + # ------------ cloudwatch ---------------- + cloudwatch: + Type : AWS::CloudFormation::Stack + Properties: + Parameters: + PJPrefix : !Ref PJPrefix + TemplateURL: ./stacks/cloudwatch.yml + # ------------ vpx ---------------- + vpc: + Type : AWS::CloudFormation::Stack + Properties: + Parameters: + PJPrefix : !Ref PJPrefix + VPCCIDR : !Sub "${VPCCIDR}" + PublicSubnet1CIDR : !Sub "${PublicSubnet1CIDR}" + PrivateSubnet1CIDR : !Sub "${PrivateSubnet1CIDR}" + PrivateSubnet2CIDR : !Sub "${PrivateSubnet2CIDR}" + TemplateURL: ./stacks/vpc.yml + # ------------ rds ---------------- + rds: + Type : AWS::CloudFormation::Stack + DependsOn : [vpc] + Properties: + Parameters: + PJPrefix : !Ref PJPrefix + DatabaseName : !Sub "/${PJPrefix}/database" + MasterUsername : !Sub "/${PJPrefix}/master/username" + MasterUserPassword : !Sub "/${PJPrefix}/master/password" + TemplateURL: stacks/rds.yml + # ------------ ecs ---------------- + ecs: + Type : AWS::CloudFormation::Stack + DependsOn : [vpc, iamRole, cloudwatch, rds] + Properties: + Parameters: + PJPrefix : !Ref PJPrefix + AppKey : !Sub "/${PJPrefix}/APP_KEY" + DatabaseName : !Sub "/${PJPrefix}/database" + MasterUsername : !Sub "/${PJPrefix}/master/username" + MasterUserPassword : !Sub "/${PJPrefix}/master/password" + TemplateURL: stacks/ecs.yml diff --git a/cloudformation-v2/output/.gitignore b/cloudformation-v2/output/.gitignore new file mode 100644 index 0000000..d1b208e --- /dev/null +++ b/cloudformation-v2/output/.gitignore @@ -0,0 +1 @@ +main-stack.yml diff --git a/cloudformation-v2/stacks/cloudwatch.yml b/cloudformation-v2/stacks/cloudwatch.yml new file mode 100644 index 0000000..d7e0692 --- /dev/null +++ b/cloudformation-v2/stacks/cloudwatch.yml @@ -0,0 +1,35 @@ +# ------------------------------------------------------------# +# Create Resource +# - CloudWatch LogGroup +# ------------------------------------------------------------# + +AWSTemplateFormatVersion: '2010-09-09' +Description: Create CloudWatch LogGroup + +Parameters: + PJPrefix: + Type: String + Default: laravel + ConstraintDescription: Invalid input value for the PJPrefix. + +Resources: +# ------------------------------------------------------------# +# LogGroup +# ------------------------------------------------------------# + LogGroup: + Type: AWS::Logs::LogGroup + Properties: + LogGroupName: !Sub "${PJPrefix}-log-group" + RetentionInDays: 30 + Tags: + - Key: Name + Value: !Sub "${PJPrefix}-log-group" + +# ------------------------------------------------------------# +# Output Parameters +# ------------------------------------------------------------# +Outputs: + LogGroup: + Value: !Ref LogGroup + Export: + Name: !Sub "${PJPrefix}-log-group" diff --git a/cloudformation-v2/stacks/ecs.yml b/cloudformation-v2/stacks/ecs.yml new file mode 100644 index 0000000..3d3b6d5 --- /dev/null +++ b/cloudformation-v2/stacks/ecs.yml @@ -0,0 +1,111 @@ +# ------------------------------------------------------------# +# Create Resource +# - Service +# - Cluster Service +# - Task Definition +# ------------------------------------------------------------# + +AWSTemplateFormatVersion: '2010-09-09' +Description: CloudFormation template for ECS resources + + +Parameters: + PJPrefix: + Type: String + Default: laravel + ConstraintDescription: Invalid input value for the PJPrefix. + AppKey: + Type : String + DatabaseName: + Type : String + MasterUsername: + Type : String + MasterUserPassword: + Type : String + +Resources: + # ECS Cluster + ECSCluster: + Type: "AWS::ECS::Cluster" + Properties: + ClusterName: !Sub "${PJPrefix}-cluster" + + # Task Definition + ECSWebTaskDefinition: + Type: "AWS::ECS::TaskDefinition" + Properties: + Family: !Sub "${PJPrefix}-run-web-task" + TaskRoleArn: + Fn::ImportValue: + !Sub "${PJPrefix}-ECSTaskRole-arn" + ExecutionRoleArn: + Fn::ImportValue: + !Sub "${PJPrefix}-ECSTaskRole-arn" + NetworkMode: "awsvpc" + ContainerDefinitions: + - Name: "nginx" + Image: !Sub "${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/${PJPrefix}/build-nginx:latest" + Essential: true + PortMappings: + - ContainerPort: 80 + HostPort: 80 + Protocol: "tcp" + Environment: + - Name: "APP_ENV" + Value: "production" + - Name: "APP_KEY" + Value: !Sub "{{resolve:ssm:${AppKey}}}" + - Name: "DB_HOST" + Value: + Fn::ImportValue: + !Sub "${PJPrefix}-rds-endpoint" + - Name: "DB_DATABASE" + Value: !Sub "{{resolve:ssm:${DatabaseName}}}" + - Name: "DB_USERNAME" + Value: !Sub "{{resolve:ssm:${MasterUsername}}}" + - Name: "DB_PASSWORD" + Value: !Sub "{{resolve:ssm:${MasterUserPassword}}}" + LogConfiguration: + LogDriver: "awslogs" + Options: + awslogs-create-group: true + awslogs-group: !Sub "${PJPrefix}-log-group" + awslogs-region: !Ref "AWS::Region" + awslogs-stream-prefix: "nginx" + RequiresCompatibilities: + - "FARGATE" + Cpu: "256" + Memory: "512" + + # ECS Service + ECSService: + Type: "AWS::ECS::Service" + DependsOn: ECSCluster + Properties: + ServiceName: !Sub "${PJPrefix}-service" + Cluster: !Ref ECSCluster + TaskDefinition: !Ref ECSWebTaskDefinition + LaunchType: FARGATE + DesiredCount: 1 + NetworkConfiguration: + AwsvpcConfiguration: + AssignPublicIp: ENABLED + Subnets: + - Fn::ImportValue: + !Sub "${PJPrefix}-private-subnet-1" + SecurityGroups: + - Fn::ImportValue: + !Sub "${PJPrefix}-SG" + +Outputs: + ClusterArn: + Value: !Ref ECSCluster + Description: The ARN of the ECS cluster + + ECSWebTaskDefinitionArn: + Description: The ARN of the created web task definition + Value: !Ref ECSWebTaskDefinition + + ServiceArn: + Value: !Ref ECSService + Description: The ARN of the ECS service diff --git a/cloudformation-v2/stacks/iam-role.yml b/cloudformation-v2/stacks/iam-role.yml new file mode 100644 index 0000000..7e94d15 --- /dev/null +++ b/cloudformation-v2/stacks/iam-role.yml @@ -0,0 +1,38 @@ +# ------------------------------------------------------------# +# Create Resource +# - IAM Role (ECSTaskRole) +# ------------------------------------------------------------# + +AWSTemplateFormatVersion: "2010-09-09" +Description: + IAM Role (ECSTaskRole) + +Parameters: + PJPrefix: + Type: String + Default: laravel + ConstraintDescription: Invalid input value for the PJPrefix. + +Resources: + ECSTaskRole: + Type: AWS::IAM::Role + Properties: + RoleName: !Sub "${PJPrefix}-ECSTaskRole" + Path: / + AssumeRolePolicyDocument: + Version: 2012-10-17 + Statement: + - Effect: Allow + Principal: + Service: ecs-tasks.amazonaws.com + Action: sts:AssumeRole + ManagedPolicyArns: + - arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy + - arn:aws:iam::aws:policy/AmazonSSMReadOnlyAccess + +Outputs: + ECSTaskRoleArn: + Description: ARN of the ECS Task Role + Value: !GetAtt ECSTaskRole.Arn + Export: + Name: !Sub "${PJPrefix}-ECSTaskRole-arn" diff --git a/cloudformation-v2/stacks/rds.yml b/cloudformation-v2/stacks/rds.yml new file mode 100644 index 0000000..9319e0e --- /dev/null +++ b/cloudformation-v2/stacks/rds.yml @@ -0,0 +1,95 @@ +# ------------------------------------------------------------# +# Create Resource +# - DBSubnetGroup +# - DBClusterParameterGroup +# - DBCluster +# - DBInstance +# ------------------------------------------------------------# +AWSTemplateFormatVersion: '2010-09-09' +Description: Create RDS + +Parameters: + PJPrefix: + Type: String + Default: laravel + ConstraintDescription: Invalid input value for the PJPrefix. + DatabaseName: + Type : String + MasterUsername: + Type : String + MasterUserPassword: + Type : String + +Resources: + # RDSを配置するサブネットを指定 + DBSubnetGroup: + Type: AWS::RDS::DBSubnetGroup + Properties: + DBSubnetGroupDescription: !Sub "${PJPrefix}-subnet-group" + SubnetIds: + - Fn::ImportValue: + !Sub "${PJPrefix}-private-subnet-1" + - Fn::ImportValue: + !Sub "${PJPrefix}-private-subnet-2" + + # RDSクラスターの動作と設定を制御するためのパラメータのセットを定義 + ClusterParameterGroup: + Type: AWS::RDS::DBClusterParameterGroup + Properties: + Description: !Sub "${PJPrefix}-parameter-group" + Family : "aurora-mysql8.0" + Parameters: + time_zone : Asia/Tokyo + character_set_client : utf8 + character_set_connection: utf8 + character_set_database : utf8 + character_set_results : utf8 + character_set_server : utf8 + + # RDSインスタンスと共有のデータベースエンジンとストレージをグループ化 + RDSCluster: + Type: AWS::RDS::DBCluster + DependsOn: DBSubnetGroup + Properties: + DBClusterIdentifier : !Sub "${PJPrefix}-cluster" + DBClusterParameterGroupName: !Ref ClusterParameterGroup + DBSubnetGroupName : !Ref DBSubnetGroup + Engine : "aurora-mysql" + DatabaseName : !Sub "{{resolve:ssm:${DatabaseName}}}" + MasterUsername : !Sub "{{resolve:ssm:${MasterUsername}}}" + MasterUserPassword : !Sub "{{resolve:ssm:${MasterUserPassword}}}" + Port : 3306 + PreferredBackupWindow : "07:00-09:00" + PreferredMaintenanceWindow : sun:05:00-sun:05:30 + + # 個別のRDSインスタンスの設定を定義 + RDSInstancePrimary: + Type: AWS::RDS::DBInstance + DependsOn: RDSCluster + Properties: + DBInstanceIdentifier : !Sub "${PJPrefix}-instance-primary" + DBInstanceClass : "db.t4g.medium" + Engine : "aurora-mysql" + AvailabilityZone : !Sub "${AWS::Region}a" + DBClusterIdentifier : !Ref RDSCluster + DBSubnetGroupName : !Ref DBSubnetGroup + PromotionTier : 1 + + RDSInstanceSecondary: + Type: AWS::RDS::DBInstance + DependsOn: RDSCluster + Properties: + DBInstanceIdentifier : !Sub "${PJPrefix}-instance-secondary" + DBInstanceClass : "db.t4g.medium" + Engine : "aurora-mysql" + AvailabilityZone : !Sub "${AWS::Region}c" + DBClusterIdentifier : !Ref RDSCluster + DBSubnetGroupName : !Ref DBSubnetGroup + PromotionTier : 2 + + +Outputs: + RDSEndpoint: + Value: !GetAtt RDSInstancePrimary.Endpoint.Address + Export: + Name: !Sub "${PJPrefix}-rds-endpoint" diff --git a/cloudformation-v2/stacks/vpc.yml b/cloudformation-v2/stacks/vpc.yml new file mode 100644 index 0000000..cd2ef53 --- /dev/null +++ b/cloudformation-v2/stacks/vpc.yml @@ -0,0 +1,334 @@ +# ------------------------------------------------------------# +# Create Resource +# - VPC +# - InternetGateway +# - PrivateSubnet +# - PublicSubnet +# - RouteTable +# - Route +# - securityGroup +# ------------------------------------------------------------# + +AWSTemplateFormatVersion: "2010-09-09" +Description: + VPC and Subnet Create + +Metadata: + "AWS::CloudFormation::Interface": + ParameterGroups: + - Label: + default: "Project Name Prefix" + Parameters: + - PJPrefix + - Label: + default: VPC + Parameters: + - VPCCIDR + - Label: + default: PublicSubnet + Parameters: + - PublicSubnet1CIDR + - Label: + default: PrivateSubnet + Parameters: + - PrivateSubnet1CIDR + +# ------------------------------------------------------------# +# Input Parameters +# ------------------------------------------------------------# +Parameters: + PJPrefix: + Type: String + Default: laravel-template + ConstraintDescription: Invalid input value for the PJPrefix. + + VPCCIDR: + Type: String + Default: 10.0.0.0/16 + MinLength: 9 + MaxLength: 18 + AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2}) + ConstraintDescription: must be a valid VPCCidrBlock. + + PublicSubnet1CIDR: + Type: String + Default: 10.0.10.0/24 + MinLength: 9 + MaxLength: 18 + AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2}) + ConstraintDescription: must be a valid PublicSubnet1CidrBlock. + + PrivateSubnet1CIDR: + Type: String + Default: 10.0.20.0/24 + MinLength: 9 + MaxLength: 18 + AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2}) + ConstraintDescription: must be a valid PrivateSubnet1CidrBlock. + + PrivateSubnet2CIDR: + Type: String + Default: 10.0.21.0/24 + MinLength: 9 + MaxLength: 18 + AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2}) + ConstraintDescription: must be a valid PrivateSubnet2CidrBlock. + +Resources: +# ------------------------------------------------------------# +# VPC +# ------------------------------------------------------------# +# VPC Create + VPC: + Type: "AWS::EC2::VPC" + Properties: + CidrBlock: !Ref VPCCIDR + EnableDnsSupport: true + EnableDnsHostnames: true + InstanceTenancy: default + Tags: + - Key: Name + Value: !Sub "${PJPrefix}-vpc" + +# InternetGateway Create + InternetGateway: + Type: "AWS::EC2::InternetGateway" + Properties: + Tags: + - Key: Name + Value: !Sub "${PJPrefix}-igw" + +# IGW Attach + InternetGatewayAttachment: + Type: "AWS::EC2::VPCGatewayAttachment" + Properties: + InternetGatewayId: !Ref InternetGateway + VpcId: !Ref VPC + +# ------------------------------------------------------------# +# Subnet +# ------------------------------------------------------------# +# Public SubnetA Create + PublicSubnet1: + Type: "AWS::EC2::Subnet" + Properties: + AvailabilityZone: !Select [ 0, !GetAZs ] + CidrBlock: !Ref PublicSubnet1CIDR + VpcId: !Ref VPC + MapPublicIpOnLaunch: true + Tags: + - Key: Name + Value: !Sub "${PJPrefix}-public-subnet-1" + +# Private SubnetA Create + PrivateSubnet1: + Type: "AWS::EC2::Subnet" + Properties: + AvailabilityZone: !Select [ 0, !GetAZs ] + CidrBlock: !Ref PrivateSubnet1CIDR + VpcId: !Ref VPC + Tags: + - Key: Name + Value: !Sub "${PJPrefix}-private-subnet-1" + +# Private SubnetC Create + PrivateSubnet2: + Type: "AWS::EC2::Subnet" + Properties: + AvailabilityZone: !Select [ 1, !GetAZs ] + CidrBlock: !Ref PrivateSubnet2CIDR + VpcId: !Ref VPC + Tags: + - Key: Name + Value: !Sub "${PJPrefix}-private-subnet-2" + +# ------------------------------------------------------------# +# RouteTable +# ------------------------------------------------------------# +# Public RouteTable1 Create + PublicRouteTable1: + Type: "AWS::EC2::RouteTable" + Properties: + VpcId: !Ref VPC + Tags: + - Key: Name + Value: !Sub "${PJPrefix}-public-route-1" + +# Private RouteTable1 Create + PrivateRouteTable1: + Type: "AWS::EC2::RouteTable" + Properties: + VpcId: !Ref VPC + Tags: + - Key: Name + Value: !Sub "${PJPrefix}-private-route-1" + +# Private RouteTable2 Create + PrivateRouteTable2: + Type: "AWS::EC2::RouteTable" + Properties: + VpcId: !Ref VPC + Tags: + - Key: Name + Value: !Sub "${PJPrefix}-private-route-2" + +# ------------------------------------------------------------# +# Routing +# ------------------------------------------------------------# +# PublicRoute1 Create + PublicRoute1: + Type: "AWS::EC2::Route" + Properties: + RouteTableId: !Ref PublicRouteTable1 + DestinationCidrBlock: "0.0.0.0/0" + GatewayId: !Ref InternetGateway + +# PrivateRoute1 Create + PrivateRoute1: + Type: "AWS::EC2::Route" + Properties: + RouteTableId: !Ref PrivateRouteTable1 + DestinationCidrBlock: "0.0.0.0/0" + NatGatewayId: !Ref NatGateway1 + +# PrivateRoute2 Create + PrivateRoute2: + Type: "AWS::EC2::Route" + Properties: + RouteTableId: !Ref PrivateRouteTable2 + DestinationCidrBlock: "0.0.0.0/0" + NatGatewayId: !Ref NatGateway1 + +# ------------------------------------------------------------# +# RouteTable Associate +# ------------------------------------------------------------# +# PublicRouteTable Associate Subnet1 + PublicSubnet1RouteTableAssociation: + Type: "AWS::EC2::SubnetRouteTableAssociation" + Properties: + SubnetId: !Ref PublicSubnet1 + RouteTableId: !Ref PublicRouteTable1 + +# PrivateRouteTable Associate Subnet1 + PrivateSubnet1RouteTableAssociation: + Type: "AWS::EC2::SubnetRouteTableAssociation" + Properties: + SubnetId: !Ref PrivateSubnet1 + RouteTableId: !Ref PrivateRouteTable1 + +# PrivateRouteTable Associate Subnet2 + PrivateSubne21RouteTableAssociation: + Type: "AWS::EC2::SubnetRouteTableAssociation" + Properties: + SubnetId: !Ref PrivateSubnet2 + RouteTableId: !Ref PrivateRouteTable2 + + # ------------------------------------------------------------# + # SecurityGroup + # ------------------------------------------------------------# + SG: + Type: AWS::EC2::SecurityGroup + Properties: + GroupName: !Sub "${PJPrefix}-SG" + GroupDescription: !Sub "${PJPrefix}-SG-Description" + VpcId: !Ref VPC + SecurityGroupEgress: + - IpProtocol: -1 + FromPort: -1 + ToPort: -1 + CidrIp: 0.0.0.0/0 + SecurityGroupIngress: + - Description: Enable HTTP access via port 80 IPv4 + IpProtocol: tcp + FromPort: 80 + ToPort: 80 + CidrIp: 0.0.0.0/0 + - Description: Enable HTTP access via port 80 IPv6 + IpProtocol: tcp + FromPort: 80 + ToPort: 80 + CidrIpv6: ::/0 + Tags: + - Key: Name + Value: !Sub "${PJPrefix}-SG" + +# ------------------------------------------------------------# +# EIP +# ------------------------------------------------------------# + EIP1: + Type: AWS::EC2::EIP + Properties: + Domain: vpc + Tags : + - Key : Name + Value: !Sub "${PJPrefix}-eip1" + +# ------------------------------------------------------------# +# NatGateway +# ------------------------------------------------------------# + NatGateway1: + Type: AWS::EC2::NatGateway + Properties: + AllocationId: !GetAtt EIP1.AllocationId + ConnectivityType: public + SubnetId: !Ref PublicSubnet1 + Tags: + - Key: Name + Value: !Sub "${PJPrefix}-nat-gateway-1" + +# ------------------------------------------------------------# +# Output Parameters +# ------------------------------------------------------------# +Outputs: +# VPC + VPC: + Value: !Ref VPC + Export: + Name: !Sub "${PJPrefix}-vpc" + + VPCCIDR: + Value: !Ref VPCCIDR + Export: + Name: !Sub "${PJPrefix}-vpc-cidr" + +# Subnet + PublicSubnet1: + Value: !Ref PublicSubnet1 + Export: + Name: !Sub "${PJPrefix}-public-subnet-1" + + PublicSubnet1CIDR: + Value: !Ref PublicSubnet1CIDR + Export: + Name: !Sub "${PJPrefix}-public-subnet-1-cidr" + + PrivateSubnet1: + Value: !Ref PrivateSubnet1 + Export: + Name: !Sub "${PJPrefix}-private-subnet-1" + + PrivateSubnet1CIDR: + Value: !Ref PrivateSubnet1CIDR + Export: + Name: !Sub "${PJPrefix}-private-subnet-1-cidr" + + PrivateSubnet1CIDR: + Value: !Ref PrivateSubnet1CIDR + Export: + Name: !Sub "${PJPrefix}-private-subnet-1-cidr" + + PrivateSubnet2: + Value: !Ref PrivateSubnet2 + Export: + Name: !Sub "${PJPrefix}-private-subnet-2" + +# Route + PublicRouteTable1: + Value: !Ref PublicRouteTable1 + Export: + Name: !Sub "${PJPrefix}-public-route-1" +# SG + SG: + Value: !Ref SG + Export: + Name: !Sub "${PJPrefix}-SG" diff --git a/docker/base/nginx/entrypoint.sh b/docker/base/nginx/entrypoint.sh index e81a435..eb190e2 100644 --- a/docker/base/nginx/entrypoint.sh +++ b/docker/base/nginx/entrypoint.sh @@ -6,19 +6,6 @@ echo "***********************************************************" echo " Starting NGINX PHP-FPM Docker Container " echo "***********************************************************" -set -e - -## Check if the supervisor config file exists -if [ -f /var/www/html/conf/worker/supervisor.conf ]; then - echo "Custom supervisor config found" - cp /var/www/html/conf/worker/supervisor.conf /etc/supervisor/conf.d/supervisor.conf - else - echo "${Red} Supervisor.conf not found" - echo "${Green} If you want to add more supervisor configs, create config file in /var/www/html/conf/worker/supervisor.conf" - echo "${Green} Start supervisor with default config..." - fi - - echo "" echo "**********************************" echo " Starting Supervisord... " diff --git a/tools/util.sh b/tools/util.sh index 218d206..81a43b4 100644 --- a/tools/util.sh +++ b/tools/util.sh @@ -76,6 +76,18 @@ deploy() rain deploy ./cloudformation/output/main-stack.yml ${PJPrefix} --profile ${AWS_PROFILE} } +subDeploy() +{ + aws cloudformation package \ + --template-file ./cloudformation-v2/main.yml \ + --s3-bucket ${PJPrefix} \ + --output-template-file ./cloudformation-v2/output/main-stack.yml \ + --profile ${AWS_PROFILE} \ + --region ${REGIN} + + rain deploy ./cloudformation-v2/output/main-stack.yml ${PJPrefix} --profile ${AWS_PROFILE} +} + batch() { aws ecs run-task \