Skip to content

Commit fa6062e

Browse files
committed
Initial commit via Backstage
0 parents  commit fa6062e

File tree

8 files changed

+368
-0
lines changed

8 files changed

+368
-0
lines changed

.github/workflows/main.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Main
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
id-token: write
14+
contents: read
15+
16+
steps:
17+
- name: Setup job workspace
18+
uses: ServerlessOpsIO/gha-setup-workspace@v1
19+
20+
- name: Assume AWS Credentials
21+
uses: ServerlessOpsIO/gha-assume-aws-credentials@v1
22+
with:
23+
build_aws_account_id: ${{ secrets.AWS_CICD_ACCOUNT_ID }}
24+
25+
- name: Install AWS SAM
26+
uses: aws-actions/setup-sam@v2
27+
28+
29+
- name: Validate template
30+
run: sam validate --lint
31+
32+
- name: Build artifact
33+
run: sam build --parallel --template template.yaml
34+
35+
- name: Store Artifacts
36+
uses: ServerlessOpsIO/gha-store-artifacts@v1
37+
with:
38+
use_aws_sam: true
39+
40+
deploy:
41+
needs:
42+
- build
43+
44+
environment: production
45+
runs-on: ubuntu-latest
46+
permissions:
47+
id-token: write
48+
contents: read
49+
50+
steps:
51+
- name: Setup job workspace
52+
uses: ServerlessOpsIO/gha-setup-workspace@v1
53+
with:
54+
checkout_artifact: true
55+
56+
- name: Assume AWS Credentials
57+
uses: ServerlessOpsIO/gha-assume-aws-credentials@v1
58+
with:
59+
build_aws_account_id: ${{ secrets.AWS_CICD_ACCOUNT_ID }}
60+
deploy_aws_account_id: ${{ secrets.DEPLOYMENT_ACCOUNT_ID }}
61+
62+
- name: Deploy via AWS SAM
63+
uses: ServerlessOpsIO/gha-deploy-aws-sam@v1
64+
with:
65+
aws_account_id: ${{ secrets.DEPLOYMENT_ACCOUNT_ID }}
66+
env_json: ${{ toJson(env) }}
67+
vars_json: ${{ toJson(vars) }}
68+
secrets_json: ${{ toJson(secrets) }}

.gitignore

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
.hypothesis/
48+
.pytest_cache/
49+
50+
# Dev
51+
.mypy_cache/
52+
53+
# pyenv / environments
54+
.python-version
55+
.env
56+
.venv
57+
env/
58+
venv/
59+
ENV/
60+
env.bak/
61+
venv.bak/
62+
63+
# IDE
64+
.settings/
65+
.project
66+
.pydevproject
67+
.vscode/
68+
*.code-workspace
69+
70+
# Mac Cruft
71+
.DS_Store
72+
73+
# Deploy
74+
codepipeline-config-*.yaml
75+
76+
77+
# AWS SAM
78+
.aws-sam/

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# tfe-ecs-cluster
2+
3+
Development / Versant / tfe-ecs-cluster

catalog-info.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
apiVersion: backstage.io/v1alpha1
3+
kind: Component
4+
metadata:
5+
name: tfe-ecs-cluster
6+
description: Terraform Enterprise
7+
namespace: default
8+
annotations:
9+
github.com/project-slug: ServerlessOpsIO/tfe-ecs-cluster
10+
io.serverlessops/cluster-type: ecs
11+
spec:
12+
type: container-cluster
13+
lifecycle: production
14+
owner: group:default/00gjdgxs1ur6lsu
15+
system: system:default/versant
16+
dependsOn:
17+
- resource:default/aws-441198202749

cfn-parameters.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"VpcId": "/org/networking/VpcId",
3+
"VpcSubnets": "/org/networking/VpcPublicSubnets",
4+
"Hostname": "tfe",
5+
"DnsZoneId": "/org/dns/ZoneId",
6+
"Domain": "development",
7+
"System": "versant",
8+
"Component": $env.GITHUB_REPOSITORY_NAME_PART_SLUG_CS,
9+
"CodeBranch": $env.GITHUB_REF_SLUG_CS
10+
}

cfn-tags.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"org:domain": "development",
3+
"org:system": "versant",
4+
"org:component": $env.GITHUB_REPOSITORY_NAME_PART_SLUG_CS
5+
}

samconfig.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# More information about the configuration file can be found here:
2+
# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html
3+
version = 0.1
4+
5+
[default]
6+
[default.global.parameters]
7+
stack_name = "tfe-ecs-cluster"
8+
9+
[default.build.parameters]
10+
cached = true
11+
parallel = true
12+
13+
[default.validate.parameters]
14+
lint = true
15+
16+
[default.deploy.parameters]
17+
capabilities = "CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND"
18+
confirm_changeset = false
19+
#resolve_s3 = true
20+
21+
[default.package.parameters]
22+
#resolve_s3 = true
23+
24+
[default.sync.parameters]
25+
watch = true
26+
27+
[default.local_start_api.parameters]
28+
warm_containers = "EAGER"
29+
30+
[default.local_start_lambda.parameters]
31+
warm_containers = "EAGER"

template.yaml

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Transform: AWS::Serverless-2016-10-31
3+
Description: >
4+
Versant tfe Cluster
5+
6+
Terraform Enterprise
7+
8+
Parameters:
9+
Domain:
10+
Type: String
11+
Description: 'Application Platform'
12+
13+
System:
14+
Type: String
15+
Description: 'Application System'
16+
17+
Component:
18+
Type: String
19+
Description: 'Application Component'
20+
21+
CodeBranch:
22+
Type: String
23+
Description: "Name of deployment branch"
24+
25+
VpcId:
26+
Type: AWS::SSM::Parameter::Value<String>
27+
Description: Account VPC ID
28+
29+
30+
VpcSubnets:
31+
Type: AWS::SSM::Parameter::Value<CommaDelimitedList>
32+
Description: Account subnets
33+
34+
Hostname:
35+
Type: String
36+
Description: Site FQDN
37+
38+
DnsZoneId:
39+
Type: AWS::SSM::Parameter::Value<String>
40+
Description: Route53 Hosted Zone ID
41+
42+
43+
44+
Resources:
45+
46+
# ALB Resources
47+
## ALB networking
48+
EcsAlbSecurityGroup:
49+
Type: AWS::EC2::SecurityGroup
50+
Properties:
51+
GroupDescription: Access to ALB for Fargate
52+
VpcId: !Ref VpcId
53+
SecurityGroupIngress:
54+
- IpProtocol: tcp
55+
CidrIp: 0.0.0.0/0
56+
FromPort: 443
57+
ToPort: 443
58+
59+
# ALB DNS Record
60+
SiteDnsRecord:
61+
Type: AWS::Route53::RecordSet
62+
Properties:
63+
HostedZoneId: !Ref DnsZoneId
64+
Name: !Ref Hostname
65+
Type: A
66+
AliasTarget:
67+
DNSName: !GetAtt EcsAlb.DNSName
68+
HostedZoneId: !GetAtt EcsAlb.CanonicalHostedZoneID
69+
70+
SiteCertificate:
71+
Type: AWS::CertificateManager::Certificate
72+
Properties:
73+
DomainName: !Ref Hostname
74+
ValidationMethod: DNS
75+
DomainValidationOptions:
76+
- DomainName: !Ref Hostname
77+
HostedZoneId: !Ref DnsZoneId
78+
79+
## ALB setup
80+
EcsAlb:
81+
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
82+
Properties:
83+
Type: application
84+
Scheme: internet-facing
85+
Subnets: !Ref VpcSubnets
86+
SecurityGroups:
87+
- !Ref EcsAlbSecurityGroup
88+
89+
EcsAlbListener:
90+
Type: AWS::ElasticLoadBalancingV2::Listener
91+
Properties:
92+
DefaultActions:
93+
- Type: fixed-response
94+
Order: 50000
95+
FixedResponseConfig:
96+
ContentType: application/json
97+
StatusCode: 200
98+
MessageBody: '{ "healthy": true }'
99+
LoadBalancerArn: !Ref 'EcsAlb'
100+
Port: 443
101+
Protocol: HTTPS
102+
Certificates:
103+
- CertificateArn: !Ref SiteCertificate
104+
105+
106+
# ECS Resources
107+
## Cluster
108+
EcsCluster:
109+
Type: AWS::ECS::Cluster
110+
111+
## ECS Network Access
112+
ContainerSecurityGroup:
113+
Type: AWS::EC2::SecurityGroup
114+
Properties:
115+
GroupDescription: Fargate container access
116+
VpcId: !Ref 'VpcId'
117+
118+
119+
ContainerAlbSecurityGroupIngress:
120+
Type: AWS::EC2::SecurityGroupIngress
121+
Properties:
122+
Description: Ingress from ALBs
123+
GroupId: !Ref ContainerSecurityGroup
124+
# All TCP ports
125+
IpProtocol: tcp
126+
FromPort: 80
127+
ToPort: 65535
128+
SourceSecurityGroupId: !Ref EcsAlbSecurityGroup
129+
130+
131+
# SSM Values
132+
EcsClusterNameSsmParam:
133+
Type: AWS::SSM::Parameter
134+
Properties:
135+
Type: String
136+
Description: Name of ECS Cluster
137+
Name: !Sub /${Domain}/${System}/${Component}/${CodeBranch}/EcsClusterName
138+
Value: !Ref EcsCluster
139+
140+
ContainerSecurityGroupIdSsmParam:
141+
Type: AWS::SSM::Parameter
142+
Properties:
143+
Type: String
144+
Description: Name of ECS Cluster
145+
Name: !Sub /${Domain}/${System}/${Component}/${CodeBranch}/ContainerSecurityGroupId
146+
Value: !Ref ContainerSecurityGroup
147+
148+
149+
EcsAlbListenerArnSsmParam:
150+
Type: AWS::SSM::Parameter
151+
Properties:
152+
Type: String
153+
Description: ARN of cluster ALB
154+
Name: !Sub /${Domain}/${System}/${Component}/${CodeBranch}/EcsAlbListenerArn
155+
Value: !Ref EcsAlbListener
156+

0 commit comments

Comments
 (0)