This file contains 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 validate_tag_name(tags: List[str]): | |
required_tag_names: Sequence[str] = ['environment', 'owner', 'projectName', 'costCentre'] | |
is_valid = True | |
for required_tag in required_tag_names: | |
if required_tag not in tags: | |
is_valid = False | |
break | |
return is_valid |
This file contains 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 shutdown_ec2_instance(ec2_client, instanceId): | |
log.info("shutting down instance-id :" + instanceId) | |
ec2_client.terminate_instances( | |
InstanceIds=[ | |
instanceId | |
] | |
) |
This file contains 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
Resources: | |
ruleEvaluationDev: | |
Type: 'AWS::Serverless::Function' | |
Properties: | |
FunctionName: 'cost-controller-function' | |
Description: 'Integrating lambda with Parameter Store' | |
Handler: 'cost_controller.cost_controller_handlers.lambda_handler' | |
Runtime: 'python3.6' | |
Role: 'arn:aws:iam::<your_account_id_here>:role/service-role/my-rule-evaluation-function' | |
Timeout: 5 |
This file contains 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 | |
Transform: 'AWS::Serverless-2016-10-31' | |
#Parameters: | |
# LambdaExecutionRole: | |
Resources: | |
ruleEvaluationDev: | |
Type: 'AWS::Serverless::Function' | |
Properties: | |
FunctionName: 'cost-controller-function' |
This file contains 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 bash | |
bucket_name=joey-my-sam-app | |
project_dir=$HOME/working/cloud-computing/lambda-demos | |
# packaging application | |
sam package \ | |
--output-template-file $project_dir/output/packaged.yaml \ | |
--s3-bucket $bucket_name > /dev/null |
This file contains 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 import Sequence | |
import logging as log | |
import boto3 | |
from typing import List | |
from botocore.exceptions import ClientError | |
from typing import Dict | |
ec2_client = boto3.client('ec2') | |
sns_client = boto3.client('sns') |
OlderNewer