mirror of
https://github.com/yeslayla/aws-ecs-jenkins.git
synced 2025-01-14 04:53:23 +01:00
112 lines
3.1 KiB
YAML
112 lines
3.1 KiB
YAML
AWSTemplateFormatVersion: '2010-09-09'
|
|
Description: Jenkins ECS Service
|
|
Parameters:
|
|
#------------------------
|
|
# Deployment Information
|
|
#------------------------
|
|
environment:
|
|
Type: String
|
|
Description: Name of the environment to use in naming.
|
|
Default: production
|
|
release:
|
|
Type: String
|
|
Description: Name of the release name of the stack version to use.
|
|
Default: production
|
|
AllowedValues: ['develop', 'production']
|
|
ConstraintDescription: "Must be a possible release version."
|
|
VpcId:
|
|
Description: ID of the VPC
|
|
Type: AWS::EC2::VPC::Id
|
|
|
|
#-------------------
|
|
# ECS Configuration
|
|
#-------------------
|
|
EcsCluster:
|
|
Type: String
|
|
Description: The cluster to run the Jenkins service on.
|
|
|
|
#-----------------
|
|
# Load Balancing
|
|
#-----------------
|
|
PublicSubnets:
|
|
Description: The public subnets for the ALB to run in.
|
|
Type: String
|
|
PortalCertificate:
|
|
Description: Arn of AWS Certificate
|
|
Type: String
|
|
|
|
#-----
|
|
# DNS
|
|
#-----
|
|
Domain:
|
|
Type: String
|
|
Description: The domain to create the endpoint on (Must have an existing hosted zone ex. `example.com`) Leave blank to skip DNS.
|
|
Default: ""
|
|
SubDomain:
|
|
Type: String
|
|
Description: The subdomain to be used by jenkins. (ex. `jenkins.example.com`)
|
|
Default: jenkins
|
|
|
|
#------------
|
|
# CloudWatch
|
|
#------------
|
|
LogGroup:
|
|
Type: String
|
|
Description: The AWS CloudWatch log group to output logs to.
|
|
Default: "/ecs/jenkins"
|
|
|
|
Conditions:
|
|
CreateDns: !Not [!Equals [!Ref Domain, ""]]
|
|
|
|
Resources:
|
|
|
|
#-----
|
|
# DNS
|
|
#-----
|
|
DnsRecords:
|
|
Condition: CreateDns
|
|
Type: AWS::CloudFormation::Stack
|
|
Properties:
|
|
TemplateURL: !Sub 'https://s3.us-east-1.amazonaws.com/sumu-stacks/jenkins/${release}/cloudformation/jenkins/dns.yaml'
|
|
Parameters:
|
|
environment: !Ref environment
|
|
Domain: !Ref Domain
|
|
SubDomain: !Ref SubDomain
|
|
JenkinsDns: !GetAtt LoadBalancing.Outputs.PublicAlbDnsName
|
|
|
|
#-----------------
|
|
# Load Balancing
|
|
#-----------------
|
|
LoadBalancing:
|
|
Type: AWS::CloudFormation::Stack
|
|
Properties:
|
|
TemplateURL: !Sub 'https://s3.us-east-1.amazonaws.com/sumu-stacks/jenkins/${release}/cloudformation/jenkins/load_balancing.yaml'
|
|
Parameters:
|
|
environment: !Ref environment
|
|
release: !Ref release
|
|
VpcId: !Ref VpcId
|
|
PublicSubnets: !Join [",", !Split [" ", !Ref PublicSubnets]]
|
|
PortalCertificate: !Ref PortalCertificate
|
|
|
|
#-------------------
|
|
# ECS Task & Service
|
|
#-------------------
|
|
TaskDefinition:
|
|
Type: AWS::CloudFormation::Stack
|
|
Properties:
|
|
TemplateURL: !Sub 'https://s3.us-east-1.amazonaws.com/sumu-stacks/jenkins/${release}/cloudformation/jenkins/task.yaml'
|
|
Parameters:
|
|
LogGroupName: !Ref LogGroup
|
|
|
|
|
|
EcsService:
|
|
DependsOn: LoadBalancing
|
|
Type: AWS::ECS::Service
|
|
Properties:
|
|
Cluster: !Ref EcsCluster
|
|
DesiredCount: 1
|
|
TaskDefinition: !GetAtt TaskDefinition.Outputs.TaskArn
|
|
LoadBalancers:
|
|
- ContainerName: jenkins
|
|
ContainerPort: 8080
|
|
TargetGroupArn: !GetAtt LoadBalancing.Outputs.AdminPortalTargetGroup |