Skip to content

Commit

Permalink
Merge pull request #21 from chriswachira/setup-diagram-as-code-with-p…
Browse files Browse the repository at this point in the history
…ython

feat(repo): introduce diagram-as-code with Python for README's Infrastructure section image
  • Loading branch information
chriswachira committed Jan 23, 2024
2 parents ba717b2 + f7e63cf commit d4bd8df
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 0 deletions.
Binary file modified assets/infrastructure.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions infrastructure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from diagrams import Diagram, Edge, Cluster
from diagrams.aws.network import CloudFront
from diagrams.aws.storage import S3
from diagrams.aws.network import Route53
from diagrams.aws.general import Users
from diagrams.onprem.vcs import Github

graph_attr = {
"pad": "0.5"
}

with Diagram(
"chriswachira.com Infrastructure",
outformat="png",
filename="assets/infrastructure",
graph_attr=graph_attr,
show=False
):
users = Users("Users")

with Cluster("AWS VPC"):
aws_services = [
Route53("\nAmazon\nRoute53"),
CloudFront("\nAmazon\nCloudFront"),
S3("\nAmazon S3")
]

route53 = aws_services[0]
cloudfront = aws_services[1]
s3_bucket = aws_services[2]

github = Github("\nGitHub\nActions")

# Users' browsers querying the chriswachira.com domain DNS from Route 53
users >> Edge(label="chriswachira.com") >> route53

# An alias A record on Route 53 mapped to CloudFront distribution's domain
route53 >> Edge(label="alias A record") >> cloudfront

# S3 bucket acting as the origin for the CloudFront distribution
cloudfront << Edge(label="S3 bucket origin") << s3_bucket

# Website files pushed from GitHub Actions to S3 bucket
s3_bucket << Edge(label="website static files") << github
174 changes: 174 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[tool.poetry]
name = "chriswachira-com"
version = "0.1.0"
description = ""
authors = ["Chris Wachira <chriskane816@gmail.com>"]
license = "MIT"
readme = "README.md"
packages = [{include = "chriswachira"}]

[tool.poetry.dependencies]
python = "^3.11"
diagrams = "^0.23.4"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

0 comments on commit d4bd8df

Please sign in to comment.