Skip to content

Commit

Permalink
added git workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
srinivasreddych committed Sep 5, 2023
1 parent 8aa7fa4 commit 27d8e21
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
23 changes: 22 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,25 @@ jobs:
- name: Static checks and linting (mypy, flake8, black, isort)
run: scripts/validate.sh --language python --path modules/ml/sagemaker-studio/
- name: Pytest
run: cd modules/ml/sagemaker-studio/ && pytest
run: cd modules/ml/sagemaker-studio/ && pytest

modules-service-catalog-app-registry:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install Requirements
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install -r modules/service-catalog/app-registry/requirements.txt
- name: Static checks and linting (mypy, flake8, black, isort)
run: scripts/validate.sh --language python --path modules/service-catalog/app-registry/
- name: Pytest
run: cd modules/service-catalog/app-registry/ && pytest
6 changes: 3 additions & 3 deletions modules/service-catalog/app-registry/modulestack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ AWSTemplateFormatVersion: 2010-09-09
Description: This template deploys a Module specific IAM permissions

Parameters:
ProjectName:
Type: String
Description: The name of the project
# ProjectName:
# Type: String
# Description: The name of the project
# DeploymentName:
# Type: String
# Description: The name of the deployment
Expand Down
18 changes: 11 additions & 7 deletions modules/service-catalog/app-registry/register-stacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import json
import os
import sys
from typing import List

import boto3
from botocore.exceptions import ClientError
Expand All @@ -16,12 +17,12 @@
CFN_CLIENT = boto3.client("cloudformation")
PROJECT_NAME = os.getenv("SEEDFARMER_PROJECT_NAME", "addf")
DEP_NAME = os.getenv("SEEDFARMER_DEPLOYMENT_NAME", "aws-solutions-wip")
APP_REG_NAME = json.loads(os.getenv("SEEDFARMER_MODULE_METADATA"))["AppRegistryName"]
APP_REG_NAME = json.loads(os.getenv("SEEDFARMER_MODULE_METADATA"))["AppRegistryName"] # type: ignore
ACTION = sys.argv[1]


def main():

def main() -> None:
"""Driver function"""
stacks_tobe_registsred = _list_stacks(prefix=f"{PROJECT_NAME}-{DEP_NAME}")

if ACTION == "associate":
Expand All @@ -30,7 +31,8 @@ def main():
_dissaociate_stacks(stacks=stacks_tobe_registsred)


def _asaociate_stacks(stacks):
def _asaociate_stacks(stacks: List[str]) -> None:
"""Associate CloudFormation Stacks to App Registry"""
for stack in stacks:
try:
APPREG_CLIENT.associate_resource(application=APP_REG_NAME, resourceType="CFN_STACK", resource=stack)
Expand All @@ -43,7 +45,9 @@ def _asaociate_stacks(stacks):
raise ex


def _dissaociate_stacks(stacks):
def _dissaociate_stacks(stacks: List[str]) -> None:
"""Dissociate CloudFormation Stacks from App Registry"""

for stack in stacks:
try:
APPREG_CLIENT.disassociate_resource(application=APP_REG_NAME, resourceType="CFN_STACK", resource=stack)
Expand All @@ -56,8 +60,8 @@ def _dissaociate_stacks(stacks):
raise ex


def _list_stacks(prefix):
"""List CFN Stacks by the desired prefix"""
def _list_stacks(prefix: str) -> List[str]:
"""List CloudFormation Stacks by the desired prefix"""

stacks_tobe_registsred = []

Expand Down
7 changes: 3 additions & 4 deletions modules/service-catalog/app-registry/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
# SPDX-License-Identifier: Apache-2.0

import logging
from typing import Any, Dict, List, cast
from typing import Any, cast

import aws_cdk
import cdk_nag
from aws_cdk import Aspects, Aws, Stack, Tags
from aws_cdk import aws_servicecatalogappregistry as appregistry
Expand All @@ -31,7 +30,7 @@ def __init__(
super().__init__(
scope,
id,
description="This stack deploys AWS AppRegistry resources for being able to visualize resources related to an AWS Solution",
description="Deploy AWS AppRegistry to visualize resources related to an AWS Solution",
**kwargs,
)

Expand All @@ -55,7 +54,7 @@ def __init__(
self,
f"{full_dep_mod}-AppRegistryApp",
name=f"{full_dep_mod}-AppRegistryApp",
description=f"Service Catalog application to track and manage all your resources for the solution {self.solution_name}",
description=f"Service Catalog app to visualize resources for the solution {self.solution_name}",
tags={
"Solutions:SolutionID": self.solution_id,
"Solutions:SolutionName": self.solution_name,
Expand Down

0 comments on commit 27d8e21

Please sign in to comment.