You've already forked microservices
mirror of
https://github.com/ebosas/microservices.git
synced 2025-06-24 22:26:56 +02:00
Create cfn task deployment
This commit is contained in:
@ -179,8 +179,8 @@ Resources:
|
||||
#-----------------------------------------------------------------------------#
|
||||
# Services
|
||||
#-----------------------------------------------------------------------------#
|
||||
- Name: Services
|
||||
Actions:
|
||||
# - Name: Services
|
||||
# Actions:
|
||||
|
||||
# - Name: Server
|
||||
# ActionTypeId:
|
||||
@ -191,7 +191,7 @@ Resources:
|
||||
# Configuration:
|
||||
# ActionMode: CREATE_UPDATE
|
||||
# RoleArn: !GetAtt CloudFormationDeployRole.Arn
|
||||
# StackName: !Sub ${EnvironmentName}-Service-Server
|
||||
# StackName: !Sub ${EnvironmentName}-Server-Service
|
||||
# TemplatePath: !Sub Source::deployments/services-${DeploymentType}/server.yml
|
||||
# Capabilities: CAPABILITY_IAM
|
||||
# ParameterOverrides: !Sub |
|
||||
@ -212,7 +212,7 @@ Resources:
|
||||
# Configuration:
|
||||
# ActionMode: CREATE_UPDATE
|
||||
# RoleArn: !GetAtt CloudFormationDeployRole.Arn
|
||||
# StackName: !Sub ${EnvironmentName}-Service-Cache
|
||||
# StackName: !Sub ${EnvironmentName}-Cache-Service
|
||||
# TemplatePath: !Sub Source::deployments/services-${DeploymentType}/cache.yml
|
||||
# Capabilities: CAPABILITY_IAM
|
||||
# ParameterOverrides: !Sub |
|
||||
@ -224,26 +224,26 @@ Resources:
|
||||
# InputArtifacts:
|
||||
# - Name: Source
|
||||
|
||||
- Name: Database
|
||||
ActionTypeId:
|
||||
Category: Deploy
|
||||
Owner: AWS
|
||||
Version: 1
|
||||
Provider: CloudFormation
|
||||
Configuration:
|
||||
ActionMode: CREATE_UPDATE
|
||||
RoleArn: !GetAtt CloudFormationDeployRole.Arn
|
||||
StackName: !Sub ${EnvironmentName}-Service-Database
|
||||
TemplatePath: !Sub Source::deployments/services-${DeploymentType}/database.yml
|
||||
Capabilities: CAPABILITY_IAM
|
||||
ParameterOverrides: !Sub |
|
||||
{
|
||||
"EnvironmentName": "${EnvironmentName}",
|
||||
"ServiceName": "database",
|
||||
"ImageUrl": "amazon/amazon-ecs-sample"
|
||||
}
|
||||
InputArtifacts:
|
||||
- Name: Source
|
||||
# - Name: Database
|
||||
# ActionTypeId:
|
||||
# Category: Deploy
|
||||
# Owner: AWS
|
||||
# Version: 1
|
||||
# Provider: CloudFormation
|
||||
# Configuration:
|
||||
# ActionMode: CREATE_UPDATE
|
||||
# RoleArn: !GetAtt CloudFormationDeployRole.Arn
|
||||
# StackName: !Sub ${EnvironmentName}-Database-Service
|
||||
# TemplatePath: !Sub Source::deployments/services-${DeploymentType}/database.yml
|
||||
# Capabilities: CAPABILITY_IAM
|
||||
# ParameterOverrides: !Sub |
|
||||
# {
|
||||
# "EnvironmentName": "${EnvironmentName}",
|
||||
# "ServiceName": "database",
|
||||
# "ImageUrl": "amazon/amazon-ecs-sample"
|
||||
# }
|
||||
# InputArtifacts:
|
||||
# - Name: Source
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
@ -261,7 +261,7 @@ Resources:
|
||||
# Configuration:
|
||||
# ActionMode: CREATE_UPDATE
|
||||
# RoleArn: !GetAtt CloudFormationDeployRole.Arn
|
||||
# StackName: !Sub ${EnvironmentName}-Pipeline-Server
|
||||
# StackName: !Sub ${EnvironmentName}-Server-Pipeline
|
||||
# TemplatePath: Source::deployments/pipeline-service.yml
|
||||
# Capabilities: CAPABILITY_IAM
|
||||
# ParameterOverrides: !Sub |
|
||||
@ -287,7 +287,7 @@ Resources:
|
||||
# Configuration:
|
||||
# ActionMode: CREATE_UPDATE
|
||||
# RoleArn: !GetAtt CloudFormationDeployRole.Arn
|
||||
# StackName: !Sub ${EnvironmentName}-Pipeline-Cache
|
||||
# StackName: !Sub ${EnvironmentName}-Cache-Pipeline
|
||||
# TemplatePath: Source::deployments/pipeline-service.yml
|
||||
# Capabilities: CAPABILITY_IAM
|
||||
# ParameterOverrides: !Sub |
|
||||
@ -313,7 +313,7 @@ Resources:
|
||||
Configuration:
|
||||
ActionMode: CREATE_UPDATE
|
||||
RoleArn: !GetAtt CloudFormationDeployRole.Arn
|
||||
StackName: !Sub ${EnvironmentName}-Pipeline-Database
|
||||
StackName: !Sub ${EnvironmentName}-Database-Pipeline
|
||||
TemplatePath: Source::deployments/pipeline-service.yml
|
||||
Capabilities: CAPABILITY_IAM
|
||||
ParameterOverrides: !Sub |
|
||||
@ -352,7 +352,7 @@ Resources:
|
||||
# Allow codepipeline to put artifacts in the S3 bucket
|
||||
# as well as get artifacts back out of it.
|
||||
- Resource: "*"
|
||||
# - !Sub arn:aws:s3:::${ArtifactBucket}/*
|
||||
# - !Sub arn:aws:s3:::${ArtifactBucket}*
|
||||
Effect: Allow
|
||||
Action:
|
||||
- s3:PutObject
|
||||
@ -469,7 +469,6 @@ Resources:
|
||||
Type: String
|
||||
Value: !Ref CloudFormationDeployRole
|
||||
|
||||
|
||||
Outputs:
|
||||
PipelineUrl:
|
||||
Value: !Sub https://console.aws.amazon.com/codepipeline/home?region=${AWS::Region}#/view/${Pipeline}
|
||||
|
@ -29,9 +29,9 @@ Parameters:
|
||||
CodePipelineServiceRoleArn:
|
||||
Type: AWS::SSM::Parameter::Value<String>
|
||||
Default: /microservices/codepipeline_service_role_arn
|
||||
# CloudFormationDeployRole:
|
||||
# Type: AWS::SSM::Parameter::Value<String>
|
||||
# Default: /microservices/cloudformation_deploy_role
|
||||
CloudFormationDeployRole:
|
||||
Type: AWS::SSM::Parameter::Value<String>
|
||||
Default: /microservices/cloudformation_deploy_role
|
||||
|
||||
Resources:
|
||||
|
||||
@ -111,17 +111,12 @@ Resources:
|
||||
Properties:
|
||||
EventPattern:
|
||||
detail:
|
||||
eventSource: [s3.amazonaws.com]
|
||||
eventName:
|
||||
- CopyObject
|
||||
- CompleteMultipartUpload
|
||||
- PutObject
|
||||
requestParameters:
|
||||
bucketName: [!Ref ArtifactBucket]
|
||||
key:
|
||||
- !Sub imagedefinitions/${ServiceName}.zip
|
||||
detail-type: [AWS API Call via CloudTrail]
|
||||
source: [aws.s3]
|
||||
action-type: [PUSH]
|
||||
image-tag: [latest]
|
||||
repository-name: [!Ref Repository]
|
||||
result: [SUCCESS]
|
||||
detail-type: [ECR Image Action]
|
||||
source: [aws.ecr]
|
||||
Targets:
|
||||
- Arn: !Sub arn:aws:codepipeline:${AWS::Region}:${AWS::AccountId}:${Pipeline}
|
||||
RoleArn: !GetAtt CloudWatchEventRole.Arn
|
||||
@ -156,34 +151,34 @@ Resources:
|
||||
- Name: Source
|
||||
Actions:
|
||||
|
||||
# - Name: Image
|
||||
# Namespace: ImageVariables
|
||||
# ActionTypeId:
|
||||
# Category: Source
|
||||
# Owner: AWS
|
||||
# Version: 1
|
||||
# Provider: ECR
|
||||
# Configuration:
|
||||
# RepositoryName: !Ref Repository
|
||||
# ImageTag: latest
|
||||
# OutputArtifacts:
|
||||
# - Name: Image
|
||||
# RunOrder: 1
|
||||
|
||||
- Name: Image
|
||||
Namespace: ImageVariables
|
||||
ActionTypeId:
|
||||
Category: Source
|
||||
Owner: AWS
|
||||
Version: 1
|
||||
Provider: S3
|
||||
Provider: ECR
|
||||
Configuration:
|
||||
S3Bucket: !Ref ArtifactBucket
|
||||
S3ObjectKey: !Sub imagedefinitions/${ServiceName}.zip
|
||||
PollForSourceChanges: false
|
||||
RepositoryName: !Ref Repository
|
||||
ImageTag: latest
|
||||
OutputArtifacts:
|
||||
- Name: Image
|
||||
RunOrder: 1
|
||||
|
||||
# - Name: Image
|
||||
# ActionTypeId:
|
||||
# Category: Source
|
||||
# Owner: AWS
|
||||
# Version: 1
|
||||
# Provider: S3
|
||||
# Configuration:
|
||||
# S3Bucket: !Ref ArtifactBucket
|
||||
# S3ObjectKey: !Sub imagedefinitions/${ServiceName}.zip
|
||||
# PollForSourceChanges: false
|
||||
# OutputArtifacts:
|
||||
# - Name: Image
|
||||
# RunOrder: 1
|
||||
|
||||
- Name: Code
|
||||
ActionTypeId:
|
||||
Category: Source
|
||||
@ -203,26 +198,6 @@ Resources:
|
||||
#-----------------------------------------------------------------------------#
|
||||
# Deploy
|
||||
#-----------------------------------------------------------------------------#
|
||||
- Name: Deploy
|
||||
Actions:
|
||||
- Name: Deploy
|
||||
ActionTypeId:
|
||||
Category: Deploy
|
||||
Owner: AWS
|
||||
Version: 1
|
||||
Provider: ECS
|
||||
Configuration:
|
||||
ClusterName:
|
||||
Fn::ImportValue: !Sub ${EnvironmentName}:ClusterName
|
||||
ServiceName: !Ref ServiceName
|
||||
# Needs imagedefinitions.json but ECR produces imageDetail.json.
|
||||
# Need a build stage to build images or transform imageDetail.json
|
||||
# as described here: https://stackoverflow.com/a/57015190
|
||||
# Or use blue/green deployment
|
||||
FileName: imagedefinitions.json
|
||||
InputArtifacts:
|
||||
- Name: Image
|
||||
|
||||
# - Name: Deploy
|
||||
# Actions:
|
||||
# - Name: Deploy
|
||||
@ -230,21 +205,42 @@ Resources:
|
||||
# Category: Deploy
|
||||
# Owner: AWS
|
||||
# Version: 1
|
||||
# Provider: CloudFormation
|
||||
# Provider: ECS
|
||||
# Configuration:
|
||||
# ActionMode: CREATE_UPDATE
|
||||
# RoleArn: !Ref CloudFormationDeployRole
|
||||
# StackName: !Sub ${EnvironmentName}-ServerService
|
||||
# TemplatePath: !Sub Code::deployments/services-${DeploymentType}/server.yml
|
||||
# Capabilities: CAPABILITY_IAM
|
||||
# ParameterOverrides: !Sub |
|
||||
# {
|
||||
# "EnvironmentName": "${EnvironmentName}",
|
||||
# "ImageUrl": "${Repository.RepositoryUri}@#{ImageVariables.ImageDigest}"
|
||||
# }
|
||||
# ClusterName:
|
||||
# Fn::ImportValue: !Sub ${EnvironmentName}:ClusterName
|
||||
# ServiceName: !Ref ServiceName
|
||||
# # Needs imagedefinitions.json but ECR produces imageDetail.json.
|
||||
# # Need a build stage to build images or transform imageDetail.json
|
||||
# # as described here: https://stackoverflow.com/a/57015190
|
||||
# # Or use blue/green deployment
|
||||
# FileName: imagedefinitions.json
|
||||
# InputArtifacts:
|
||||
# - Name: Image
|
||||
# - Name: Code
|
||||
|
||||
- Name: Deploy
|
||||
Actions:
|
||||
- Name: Deploy
|
||||
ActionTypeId:
|
||||
Category: Deploy
|
||||
Owner: AWS
|
||||
Version: 1
|
||||
Provider: CloudFormation
|
||||
Configuration:
|
||||
ActionMode: CREATE_UPDATE
|
||||
RoleArn: !Ref CloudFormationDeployRole
|
||||
StackName: !Sub ${EnvironmentName}-Server-Service
|
||||
TemplatePath: !Sub Code::deployments/services-${DeploymentType}/server.yml
|
||||
Capabilities: CAPABILITY_IAM
|
||||
ParameterOverrides: !Sub |
|
||||
{
|
||||
"EnvironmentName": "${EnvironmentName}",
|
||||
"ServiceName": "${ServiceName}",
|
||||
"ImageUrl": "${Repository.RepositoryUri}@#{ImageVariables.ImageDigest}"
|
||||
}
|
||||
InputArtifacts:
|
||||
- Name: Image
|
||||
- Name: Code
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
# Role for CodeBuild service
|
||||
|
Reference in New Issue
Block a user