1
0
mirror of https://github.com/ebosas/microservices.git synced 2025-08-24 20:08:55 +02:00

Create new pipeline

This commit is contained in:
ebosas
2021-11-14 16:07:11 +02:00
parent 3fcd686b3f
commit d8bf928103
3 changed files with 17 additions and 145 deletions

View File

@@ -1,129 +0,0 @@
AWSTemplateFormatVersion: '2010-09-09'
Description: AWS Fargate cluster that can span public and private subnets.
Parameters:
EnvironmentName:
Type: String
Default: production
Description: "A friendly environment name that will be used for namespacing all cluster resources. Example: staging, qa, or production"
Resources:
# ECS Resources
ECSCluster:
Type: AWS::ECS::Cluster
# A role used to allow AWS Autoscaling to inspect stats and adjust scaleable targets
# on your AWS account
AutoscalingRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: [application-autoscaling.amazonaws.com]
Action: ['sts:AssumeRole']
Path: /
Policies:
- PolicyName: service-autoscaling
PolicyDocument:
Statement:
- Effect: Allow
Action:
- 'application-autoscaling:*'
- 'cloudwatch:DescribeAlarms'
- 'cloudwatch:PutMetricAlarm'
- 'ecs:DescribeServices'
- 'ecs:UpdateService'
Resource: '*'
# # This is an IAM role which authorizes ECS to manage resources on your
# # account on your behalf, such as updating your load balancer with the
# # details of where your containers are, so that traffic can reach your
# # containers.
# ECSRole:
# 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:
# # Rules which allow ECS to attach network interfaces to instances
# # on your behalf in order for awsvpc networking mode to work right
# - 'ec2:AttachNetworkInterface'
# - 'ec2:CreateNetworkInterface'
# - 'ec2:CreateNetworkInterfacePermission'
# - 'ec2:DeleteNetworkInterface'
# - 'ec2:DeleteNetworkInterfacePermission'
# - 'ec2:Describe*'
# - 'ec2:DetachNetworkInterface'
# # Rules which allow ECS to update load balancers on your behalf
# # with the information sabout how to send traffic to your containers
# - 'elasticloadbalancing:DeregisterInstancesFromLoadBalancer'
# - 'elasticloadbalancing:DeregisterTargets'
# - 'elasticloadbalancing:Describe*'
# - 'elasticloadbalancing:RegisterInstancesWithLoadBalancer'
# - 'elasticloadbalancing:RegisterTargets'
# Resource: '*'
# This is a role which is used by the ECS tasks themselves
# (AmazonECSTaskExecutionRolePolicy)
ECSTaskExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: [ecs-tasks.amazonaws.com]
Action: ['sts:AssumeRole']
Path: /
Policies:
- PolicyName: AmazonECSTaskExecutionRolePolicy
PolicyDocument:
Statement:
- Effect: Allow
Action:
# Allow the ECS Tasks to download images from ECR
- 'ecr:GetAuthorizationToken'
- 'ecr:BatchCheckLayerAvailability'
- 'ecr:GetDownloadUrlForLayer'
- 'ecr:BatchGetImage'
# Allow the ECS tasks to upload logs to CloudWatch
- 'logs:CreateLogStream'
- 'logs:PutLogEvents'
Resource: '*'
# These are the values output by the CloudFormation template. Be careful
# about changing any of them, because of them are exported with specific
# names so that the other task related CF templates can use them.
Outputs:
ClusterName:
Description: The name of the ECS cluster
Value: !Ref 'ECSCluster'
Export:
Name: !Sub ${EnvironmentName}:ClusterName
AutoscalingRole:
Description: The ARN of the role used for autoscaling
Value: !GetAtt 'AutoscalingRole.Arn'
Export:
Name: !Sub ${EnvironmentName}:AutoscalingRole
# ECSRole:
# Description: The ARN of the ECS role
# Value: !GetAtt 'ECSRole.Arn'
# Export:
# Name: !Sub ${EnvironmentName}:ECSRole
ECSTaskExecutionRole:
Description: The ARN of the ECS role
Value: !GetAtt 'ECSTaskExecutionRole.Arn'
Export:
Name: !Sub ${EnvironmentName}:ECSTaskExecutionRole

View File

@@ -4,7 +4,8 @@ Parameters:
EnvironmentName:
Type: String
Default: production
Description: "A friendly environment name that will be used for namespacing all cluster resources. Example: staging, qa, or production"
Description: A friendly environment name that will be used for namespacing all
cluster resources, for example staging, qa, or production
Mappings:
# Hard values for the subnet masks. These masks define

View File

@@ -31,15 +31,15 @@ Resources:
VersioningConfiguration:
Status: Enabled
#-----------------------------------------------------------------------------#
# Source Credentials (for CodeBuild)
#-----------------------------------------------------------------------------#
SourceCredentials:
Type: AWS::CodeBuild::SourceCredential
Properties:
Token: !Ref GitHubToken
ServerType: GITHUB
AuthType: PERSONAL_ACCESS_TOKEN
# #-----------------------------------------------------------------------------#
# # Source Credentials (for CodeBuild)
# #-----------------------------------------------------------------------------#
# SourceCredentials:
# Type: AWS::CodeBuild::SourceCredential
# Properties:
# Token: !Ref GitHubToken
# ServerType: GITHUB
# AuthType: PERSONAL_ACCESS_TOKEN
#-----------------------------------------------------------------------------#
# CodePipeline
@@ -204,9 +204,9 @@ Resources:
# "EnvironmentName": "${EnvironmentName}",
# "LaunchType": "${LaunchType}",
# "ImageUrl": "amazon/amazon-ecs-sample",
# "ContainerMemory": ${memory}
# "ContainerMemory": "${memory}"
# }
# - memory: !If [ Fargate, 512, 230 ]
# - memory: !If [ Fargate, 512, 240 ]
# InputArtifacts:
# - Name: Source
@@ -229,9 +229,9 @@ Resources:
# "EnvironmentName": "${EnvironmentName}",
# "LaunchType": "${LaunchType}",
# "ImageUrl": "amazon/amazon-ecs-sample",
# "ContainerMemory": ${memory}
# "ContainerMemory": "${memory}"
# }
# - memory: !If [ Fargate, 512, 230 ]
# - memory: !If [ Fargate, 512, 240 ]
# InputArtifacts:
# - Name: Source
@@ -254,9 +254,9 @@ Resources:
"EnvironmentName": "${EnvironmentName}",
"LaunchType": "${LaunchType}",
"ImageUrl": "amazon/amazon-ecs-sample",
"ContainerMemory": ${memory}
"ContainerMemory": "${memory}"
}
- memory: !If [ Fargate, 512, 230 ]
- memory: !If [ Fargate, 512, 240 ]
InputArtifacts:
- Name: Source