Skip to content

Commit

Permalink
Initial commit via Backstage
Browse files Browse the repository at this point in the history
  • Loading branch information
tmclaugh committed Dec 29, 2024
0 parents commit d08edf0
Show file tree
Hide file tree
Showing 37 changed files with 696 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .cfnlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore_checks:
- E3034 # Template too short
74 changes: 74 additions & 0 deletions .github/workflows/feature-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Feature Branch
on:
workflow_dispatch:
push:
branches:
- feature/*
- fix/*

jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

steps:
- name: Setup job workspace
uses: ServerlessOpsIO/gha-setup-workspace@v1

- name: Setup Python environment
uses: ServerlessOpsIO/gha-setup-python@v1
with:
python_version: '3.13'

- name: Run tests
run: pipenv run test-unit

- name: Assume AWS credentials
uses: ServerlessOpsIO/gha-assume-aws-credentials@v1
with:
build_aws_account_id: ${{ secrets.AWS_CICD_ACCOUNT_ID }}

- name: Install AWS SAM
uses: aws-actions/setup-sam@v2

- name: Validate template
run: sam validate --lint

- name: Build deployment artifact
run: sam build

- name: Store artifacts
uses: ServerlessOpsIO/gha-store-artifacts@v1
with:
use_aws_sam: true

deploy:
needs:
- build

environment: production
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

steps:
- name: Setup job workspace
uses: ServerlessOpsIO/gha-setup-workspace@v1
with:
checkout_artifact: true

- name: Assume AWS credentials
uses: ServerlessOpsIO/gha-assume-aws-credentials@v1
with:
build_aws_account_id: ${{ secrets.AWS_CICD_ACCOUNT_ID }}
deploy_aws_account_id: ${{ secrets.DEPLOYMENT_ACCOUNT_ID }}

- name: Deploy via AWS SAM
uses: ServerlessOpsIO/gha-deploy-aws-sam@v1
with:
aws_account_id: ${{ secrets.DEPLOYMENT_ACCOUNT_ID }}
env_json: ${{ toJson(env) }}
secrets_json: ${{ toJson(secrets) }}
74 changes: 74 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Main

on:
workflow_dispatch:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

steps:
- name: Setup job workspace
uses: ServerlessOpsIO/gha-setup-workspace@v1

- name: Setup Python environment
uses: ServerlessOpsIO/gha-setup-python@v1
with:
python_version: '3.13'

- name: Run tests
run: pipenv run test-unit

- name: Assume AWS credentials
uses: ServerlessOpsIO/gha-assume-aws-credentials@v1
with:
build_aws_account_id: ${{ secrets.AWS_CICD_ACCOUNT_ID }}

- name: Install AWS SAM
uses: aws-actions/setup-sam@v2

- name: Validate template
run: sam validate --lint

- name: Build deployment artifact
run: sam build

- name: Store artifacts
uses: ServerlessOpsIO/gha-store-artifacts@v1
with:
use_aws_sam: true

deploy:
needs:
- build

environment: production
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

steps:
- name: Setup job workspace
uses: ServerlessOpsIO/gha-setup-workspace@v1
with:
checkout_artifact: true

- name: Assume AWS credentials
uses: ServerlessOpsIO/gha-assume-aws-credentials@v1
with:
build_aws_account_id: ${{ secrets.AWS_CICD_ACCOUNT_ID }}
deploy_aws_account_id: ${{ secrets.DEPLOYMENT_ACCOUNT_ID }}

- name: Deploy via AWS SAM
uses: ServerlessOpsIO/gha-deploy-aws-sam@v1
with:
aws_account_id: ${{ secrets.DEPLOYMENT_ACCOUNT_ID }}
env_json: ${{ toJson(env) }}
secrets_json: ${{ toJson(secrets) }}
81 changes: 81 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Dev
.mypy_cache/

# pyenv / environments
.python-version
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# IDE
.settings/
.project
.pydevproject
.vscode/
*.code-workspace
.idea/

# Mac Cruft
.DS_Store
Thumbs.db

# IDE
.vscode
!.vscode/launch.json
!.vscode/tasks.json

# AWS SAM
.aws-sam/
39 changes: 39 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[requires]
python_version = "3.13"

[packages]
common = {editable = true, path = "src/common"}
aws-lambda-powertools = "*"

[dev-packages]
boto3-stubs = { extras = [ "sns", ], version = "*"}
cfn-lint = "*"
flake8 = "*"
genson = "*"
jsonschema = "*"
json2python-models = "*"
moto = { extras = [ "sns", ], version = "*"}
mypy = "*"
pylint = "*"
pytest = "*"
pytest-cov = "*"
pytest-flake8 = "*"
pytest-mock = "*"
pytest-mypy = "*"
pytest-pylint = "*"
tox = "*"

[scripts]
test = "pytest -vv --cov src --cov-report term-missing --cov-fail-under 95 tests"
test-unit = "pytest -vv --cov src --cov-report term-missing --cov-fail-under 95 tests/unit"
test-int = "pytest -vv --cov src --cov-report term-missing --cov-fail-under 95 tests/integration"
test-ete = "pytest -vv --cov src --cov-report term-missing --cov-fail-under 95 tests/ete"
flake8 = "pytest -vv --flake8"
pylint = "pytest -vv --pylint"
mypy = "pytest -vv --mypy"

13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# backstage / backstage-aws-resource-collector

Collect resources from AWS accounts


## New Project Getting Started
This repository was generated from a template intended to get a new API up and running quickly. This section will cover different aspects of the newly created project as well as areas that may need to be modified to meet the specific needs of a new project.


### Code
When starting a new project the first place to start with adapting the code to meet the needs of a new project is the [`src/common/common/model/.py`](src/common/common/model/.py) file. This file contains interfaces for data and DDB table items.

Start by modifying the dataclasses to match the shape of your data. Optionally you can choose to replace that interface with one from another module if you're working with a pre-existing data model. The existing interface definition was chosen simply to make the project work out of the box.
16 changes: 16 additions & 0 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: backstage-aws-resource-collector
description: Collect resources from AWS accounts
annotations:
github.com/project-slug: ServerlessOpsIO/backstage-aws-resource-collector
spec:
type: api
lifecycle: production
owner: group:backstage
system: system:backstage
providesApis:
- resource:backstage-aws-resource-collector

7 changes: 7 additions & 0 deletions cfn-parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

{
"Domain": "devtools",
"System": "backstage",
"Component": $env.GITHUB_REPOSITORY_NAME_PART_SLUG_CS,
"CodeBranch": $env.GITHUB_REF_SLUG_CS
}
5 changes: 5 additions & 0 deletions cfn-tags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"org:domain": "devtools",
"org:system": "backstage",
"org:component": $env.GITHUB_REPOSITORY_NAME_PART_SLUG_CS
}
1 change: 1 addition & 0 deletions data/handlers/ListAccounts/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
7 changes: 7 additions & 0 deletions data/handlers/ListAccounts/data.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Event",
"type": "object",
"properties": {},
"additionalProperties": true
}
13 changes: 13 additions & 0 deletions data/handlers/ListAccounts/event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "0",
"id": "bb675cb9-4cf4-4e6e-8a2e-9f17d21465d8",
"detail-type": "Scheduled Event",
"source": "aws.scheduler",
"account": "123456789012",
"time": "2024-12-13T22:46:36Z",
"region": "us-east-1",
"resources": [
"arn:aws:scheduler:us-east-1:123456789012:schedule/default/ScheduledProcessorFunctionSchedule"
],
"detail": "{}"
}
Loading

0 comments on commit d08edf0

Please sign in to comment.