Skip to content

Commit 260fdcf

Browse files
William ChrispJoshArmi
authored andcommitted
Clean up makefile, pipenv and workflows.
1 parent 5b38e39 commit 260fdcf

34 files changed

+1388
-485
lines changed

.github/workflows/aws_cicd.yaml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: cicd
1+
name: aws-cicd
22
on:
33
push:
44
branches:
@@ -15,8 +15,6 @@ jobs:
1515
permissions:
1616
id-token: write
1717
contents: read
18-
env:
19-
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }}
2018
steps:
2119
- name: Checkout
2220
uses: actions/checkout@v3
@@ -34,7 +32,7 @@ jobs:
3432

3533
- uses: actions/setup-python@v4
3634
with:
37-
python-version: "3.10"
35+
python-version: "3.9"
3836

3937
- name: Install pipenv
4038
run: pip install pipenv
@@ -53,10 +51,10 @@ jobs:
5351
run: make unittest
5452

5553
- name: Synthesize terraform configuration template
56-
run: make build
54+
run: make aws-synth
5755

5856
- name: Dev deployment
59-
run: make deploy
57+
run: make aws-deploy-all INFRA_ARGS=--auto-approve
6058

6159
- name: Perform full test and check coverage
6260
run: make test
@@ -74,11 +72,8 @@ jobs:
7472
- name: Prepare for production deployment
7573
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
7674
run: make clean
77-
env:
78-
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY_PROD }}
7975

8076
- name: Production deployment
8177
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
82-
run: make deploy
83-
env:
84-
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY_PROD }}
78+
run: make aws-deploy-all INFRA_ARGS=--auto-approve
79+

.github/workflows/gcp_cicd.yaml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: cicd
1+
name: gcp-cicd
22
on:
33
push:
44
branches:
@@ -33,7 +33,7 @@ jobs:
3333

3434
- uses: actions/setup-python@v4
3535
with:
36-
python-version: "3.10"
36+
python-version: "3.9"
3737

3838
- name: Install pipenv
3939
run: pip install pipenv
@@ -49,19 +49,16 @@ jobs:
4949
run: make install-dependencies
5050

5151
- name: Synthesize terraform configuration template
52-
run: make synth-gcp
53-
54-
- name: Terraform plan
55-
run: make plan-gcp
52+
run: make gcp-synth
5653

5754
- name: Deploy base infrastructure
58-
run: make deploy-base-gcp
55+
run: make gcp-deploy-base INFRA_ARGS=--auto-approve
5956

6057
- name: Build & push docker image
61-
run: make build-image
58+
run: make gcp-build-image
6259

6360
- name: Deploy main infrastructure
64-
run: make deploy-main-gcp
61+
run: make gcp-deploy-core INFRA_ARGS=--auto-approve
6562

6663
# - name: Perform full test and check coverage
6764
# run: make test

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ Thumbs.db
257257

258258
# CDKTF Specifics
259259
requirements.txt
260-
all_files/
260+
controller_core/
261261
api_key_rotation/
262262
!api_key_rotation/main.py
263263
imports/

10_oidc/role.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ resource "aws_iam_role" "github_oidc" {
1818
Condition = {
1919
StringLike = {
2020
"token.actions.githubusercontent.com:aud" = "sts.amazonaws.com"
21-
"token.actions.githubusercontent.com:sub" = "repo:contino/apac-flight-controller-aws:*"
21+
"token.actions.githubusercontent.com:sub" = "repo:contino/flight-controller:*"
2222
}
2323
}
2424
},

11_oidc_prod/role.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ resource "aws_iam_role" "github_oidc" {
1818
Condition = {
1919
StringEquals = {
2020
"token.actions.githubusercontent.com:aud" = "sts.amazonaws.com"
21-
"token.actions.githubusercontent.com:sub" = "repo:contino/apac-flight-controller-aws:ref:refs/heads/main"
21+
"token.actions.githubusercontent.com:sub" = "repo:contino/flight-controller:ref:refs/heads/main"
2222
}
2323
}
2424
},

Makefile

Lines changed: 100 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
INFRA_ARGS =
2+
13
# Local Commands
24
local: install-dependencies
35
pipenv shell
46

57
install-dependencies:
8+
pipenv clean
69
pipenv install --dev
710

811
docs-install:
@@ -34,67 +37,122 @@ e2e:
3437
cd tests/; pipenv run behave
3538

3639
# Infrastructure Commands
37-
build-python:
38-
pipenv requirements | tee requirements.txt
39-
rsync -avu $(shell pwd)/src $(shell pwd)/infrastructure/aws/all_files
40-
pip install -r requirements.txt --target=$(shell pwd)/infrastructure/aws/all_files
41-
pip install boto3 --target=$(shell pwd)/infrastructure/aws/api_key_rotation
42-
cd infrastructure/aws; cdktf provider add grafana/grafana
43-
cd infrastructure/gcp; cdktf provider add grafana/grafana
4440

41+
# General
4542
clean:
4643
cd infrastructure/aws; rm -rf cdktf.out
4744
cd infrastructure/gcp; rm -rf cdktf.out
4845

49-
synth-aws:
50-
cd infrastructure/aws;cdktf synth aws_infra_cdktf
51-
52-
synth-grafana:
53-
cd infrastructure/aws;cdktf synth grafana
46+
synth: aws-synth gcp-synth
5447

55-
synth-gcp:
56-
cd infrastructure/gcp; cdktf provider add grafana/grafana
57-
cd infrastructure/gcp; cdktf synth base_gcp_infra
58-
cd infrastructure/gcp; cdktf synth main_gcp_infra
59-
60-
synth: synth-aws synth-grafana synth-gcp
48+
plan: aws-plan-all gcp-plan-all
6149

62-
build: build-python synth
50+
deploy: aws-deploy-all gcp-deploy-all
6351

64-
plan-aws:
65-
cd infrastructure/aws;cdktf plan aws_infra_cdktf
52+
destroy: aws-destroy-all gcp-destroy-all
6653

67-
plan-grafana:
68-
cd infrastructure/aws;cdktf plan grafana
54+
# AWS
55+
aws-build-dependencies:
56+
@echo "\n\n---AWS-BUILD-DEPENDENCIES---\n"
57+
rsync -avu $(shell pwd)/src $(shell pwd)/infrastructure/aws/controller_core
58+
pipenv requirements | tee requirements.txt
59+
pip install -r requirements.txt --target=$(shell pwd)/infrastructure/aws/controller_core
60+
pip install boto3 --target=$(shell pwd)/infrastructure/aws/api_key_rotation
61+
cd infrastructure/aws; cdktf provider add grafana/grafana
62+
63+
aws-synth: aws-build-dependencies
64+
@echo "\n\n---AWS-SYNTH---\n"
65+
cd infrastructure/aws;cdktf synth
6966

70-
plan-gcp:
71-
cd infrastructure/gcp;cdktf plan base_gcp_infra main_gcp_infra
67+
aws-plan-core:
68+
@echo "\n\n---AWS-PLAN-CORE---\n"
69+
cd infrastructure/aws;cdktf plan aws_core
7270

73-
plan-gcp-grafana:
74-
cd infrastructure/gcp;cdktf plan grafana
71+
aws-plan-grafana:
72+
@echo "\n\n---AWS-PLAN-GRAFANA---\n"
73+
cd infrastructure/aws;cdktf plan aws_grafana_dashboard
7574

76-
plan: build-python plan-aws plan-grafana plan-gcp
75+
aws-plan-all: aws-plan-core aws-plan-grafana
7776

78-
plan-gcpstack: plan-gcp plan-grafana
77+
aws-deploy-core:
78+
@echo "\n\n---AWS-DEPLOY-CORE---\n"
79+
cd infrastructure/aws;cdktf deploy aws_core ${INFRA_ARGS}
7980

80-
deploy:
81-
cd infrastructure/aws;cdktf deploy aws_infra_cdktf grafana --auto-approve
81+
aws-deploy-grafana:
82+
@echo "\n\n---AWS-DEPLOY-GRAFANA---\n"
83+
cd infrastructure/aws;cdktf deploy aws_grafana_dashboard ${INFRA_ARGS}
8284

83-
destroy-aws:
84-
cd infrastructure/aws;cdktf destroy aws_infra_cdktf
85+
aws-deploy-all:
86+
@echo "\n\n---AWS-DEPLOY-ALL---\n"
87+
cd infrastructure/aws;cdktf deploy aws_core aws_grafana_dashboard ${INFRA_ARGS}
8588

86-
destroy-grafana:
87-
cd infrastructure/aws;cdktf destroy grafana
89+
aws-destroy-core:
90+
@echo "\n\n---AWS-DESTROY-CORE---\n"
91+
cd infrastructure/aws;cdktf destroy aws_core
8892

89-
destroy: destroy-core destroy-grafana
93+
aws-destroy-grafana:
94+
@echo "\n\n---AWS-DESTROY-GRAFANA---\n"
95+
cd infrastructure/aws;cdktf destroy aws_grafana_dashboard
9096

91-
deploy-base-gcp:
92-
cd infrastructure/gcp; cdktf deploy base_gcp_infra --auto-approve
97+
aws-destroy-all:
98+
@echo "\n\n---AWS-DESTROY-ALL---\n"
99+
cd infrastructure/aws;cdktf destroy aws_core aws_grafana_dashboard
93100

94-
deploy-main-gcp:
95-
cd infrastructure/gcp; cdktf deploy base_gcp_infra main_gcp_infra --auto-approve
101+
# GCP
102+
gcp-build-dependencies:
103+
@echo "\n\n---GCP-BUILD-DEPENDENCIES---\n"
104+
cd infrastructure/gcp; cdktf provider add grafana/grafana
96105

97-
build-image:
106+
gcp-build-image:
107+
@echo "\n\n---GCP-BUILD-IMAGE---\n"
98108
gcloud auth configure-docker australia-southeast1-docker.pkg.dev
99109
pipenv requirements | tee requirements.txt
100-
docker buildx build --platform=linux/amd64 --push . -t australia-southeast1-docker.pkg.dev/contino-squad0-fc/flight-contoller-event-receiver/event_receiver:latest
110+
docker buildx build --platform=linux/amd64 --push . -t australia-southeast1-docker.pkg.dev/contino-squad0-fc/flight-contoller-event-receiver/event_receiver:latest
111+
112+
gcp-synth: gcp-build-dependencies
113+
@echo "\n\n---GCP-SYNTH---\n"
114+
cd infrastructure/gcp; cdktf synth
115+
116+
gcp-plan-base:
117+
@echo "\n\n---GCP-PLAN-BASE---\n"
118+
cd infrastructure/gcp;cdktf plan gcp_base
119+
120+
gcp-plan-core:
121+
@echo "\n\n---GCP-PLAN-CORE---\n"
122+
cd infrastructure/gcp;cdktf plan gcp_core
123+
124+
gcp-plan-grafana:
125+
@echo "\n\n---GCP-PLAN-GRAFANA---\n"
126+
cd infrastructure/gcp;cdktf plan gcp_grafana
127+
128+
gcp-plan-all: gcp-plan-base gcp-plan-core #gcp-plan-grafana
129+
130+
gcp-deploy-base:
131+
@echo "\n\n---GCP-DEPLOY-BASE---\n"
132+
cd infrastructure/gcp;cdktf deploy gcp_base ${INFRA_ARGS}
133+
134+
gcp-deploy-core:
135+
@echo "\n\n---GCP-DEPLOY-CORE---\n"
136+
cd infrastructure/gcp;cdktf deploy gcp_base gcp_core ${INFRA_ARGS}
137+
138+
gcp-deploy-grafana:
139+
@echo "\n\n---GCP-DEPLOY-GRAFANA---\n"
140+
cd infrastructure/gcp;cdktf deploy gcp_grafana ${INFRA_ARGS}
141+
142+
gcp-deploy-all: gcp-deploy-base gcp-build-image gcp-deploy-core #gcp-deploy-grafana
143+
144+
gcp-destroy-base:
145+
@echo "\n\n---GCP-DESTROY-BASE---\n"
146+
cd infrastructure/gcp;cdktf destroy gcp_base
147+
148+
gcp-destroy-core:
149+
@echo "\n\n---GCP-DESTROY-CORE---\n"
150+
cd infrastructure/gcp;cdktf destroy gcp_core
151+
152+
gcp-destroy-grafana:
153+
@echo "\n\n---GCP-DESTROY-GRAFANA---\n"
154+
cd infrastructure/gcp;cdktf destroy gcp_grafana
155+
156+
gcp-destroy-all:
157+
@echo "\n\n---GCP-DESTROY-ALL---\n"
158+
cd infrastructure/gcp;cdktf destroy gcp_base gcp_core gcp_grafana

Pipfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ structlog = "*"
1111
boto3= "*"
1212
flask = "*"
1313
pydantic = "*"
14+
pydantic-core = "*"
1415

1516
[dev-packages]
1617
pytest = "*"
@@ -30,7 +31,7 @@ pytest-watch = "*"
3031
dirhash = "*"
3132

3233
[requires]
33-
python_version = "3.10"
34+
python_version = "3.9"
3435

3536
[pipenv]
36-
allow_prereleases = true
37+
allow_prereleases = true

0 commit comments

Comments
 (0)