This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import boto3 | |
| import psycopg2 | |
| import logging | |
| def lambda_handler(event, context): | |
| ssm_client = boto3.client('ssm') | |
| logger = logging.getLogger('INIT-DB') | |
| logger.setLevel(logging.INFO) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ################################################################################ | |
| # EC2 BASTION | |
| ################################################################################ | |
| module "bastion_host_sgroup" { | |
| source = "terraform-aws-modules/security-group/aws" | |
| version = "~> 4" | |
| name = "${var.env}-${var.project}-bastion-sg" | |
| description = "Bastion Host security group" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AWSTemplateFormatVersion: 2010-09-09 | |
| Description: Medium custom lambda stack | |
| Resources: | |
| CustomBackedLambda: | |
| Type: AWS::Lambda::Function | |
| Properties: | |
| FunctionName: CustomBackedLambda | |
| Runtime: python3.9 | |
| Role: my_iam_role |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing_extensions import runtime | |
| import os | |
| from aws_cdk import ( | |
| core, | |
| aws_lambda as _lambda, | |
| aws_iam as iam | |
| ) | |
| class MediumLambdaStack(core.Stack): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "app": "python3 app.py", | |
| "context": { | |
| "@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true, | |
| "@aws-cdk/core:enableStackNameDuplicates": "true", | |
| "aws-cdk:enableDiffNoFail": "true", | |
| "@aws-cdk/core:stackRelativeExports": "true", | |
| "@aws-cdk/aws-ecr-assets:dockerIgnoreSupport": true, | |
| "@aws-cdk/aws-secretsmanager:parseOwnedSecretName": true, | |
| "@aws-cdk/aws-kms:defaultKeyPolicies": true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import os | |
| from aws_cdk import core | |
| from medium.stack import MediumLambdaStack | |
| myenv = os.environ['MYENV'] | |
| # Init of the main application (stack) | |
| app = core.App() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if __name__ == "__main__": | |
| c = DRP("MY_ACCOUNT") | |
| for az in c.describeAZ(): | |
| main_logger = logging.getLogger('MAIN') | |
| main_logger.info('Begin of the operations on az: %s', az) | |
| waitUserInput() | |
| c.addActionToDf("[{} / {}] Begin of the operations".format(c.env, az)) | |
| # 0) Create a new az_list without our AZ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def dumpConfigToDisk(self, comp, az): | |
| # Dump config file to disk as backup | |
| pass | |
| def addActionToDf(self, action): | |
| # Add action to DataFrame | |
| pass | |
| def dumpDfToDisk(self): | |
| # Dump DF to disk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def assumeRole(self, action): | |
| client = self.initStsClient() | |
| assumedRoleObject = client.assume_role( | |
| RoleArn="arn:aws:iam::"+self.aws_accounts[self.env]["id"]+":role/"+self.aws_accounts[self.env]["role"], | |
| RoleSessionName="Drp-" + action | |
| ) | |
| credentials=assumedRoleObject['Credentials'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for i, item in enumerate(tournament_idx_lst[:-1]): | |
| tournament_name = rows[item].find("td", class_="t-name").text.strip() | |
| if "Pro Tennis" in tournament_name or "Futures" in tournament_name or "challenger" in tournament_name: | |
| continue | |
| if not tournament_dict.get(tournament_name): | |
| tournament_dict[tournament_name] = {} | |
| tournament_dict[tournament_name][current_date] = [] | |
| for c in range (item+1, tournament_idx_lst[i+1], 2): | |
| tournament_dict[tournament_name][current_date].append(getPlayersFullName(rows[c].find("td", class_="t-name").a['href']) + ' vs ' + getPlayersFullName(rows[c+1].find("td", class_="t-name").a['href'])) |