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 boto3 | |
| ecs = boto3.client('ecs') | |
| ssm = boto3.client('ssm') | |
| cluster_name = “sample-cluster” | |
| service_name = “sample-service” | |
| # To stop the tasks | |
| response = ecs.describe_services( | |
| cluster=cluster_name, |
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
| description: Triggers AWS Lambda Fargate Function | |
| schemaVersion: '0.3' | |
| parameters: | |
| Region: | |
| description: (Required) Name of the Region | |
| type: String | |
| default: us-east-1 | |
| Cluster: | |
| description: (Required) Name of the ECS cluster | |
| type: String |
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
| # Checks if an image tag exists in the repo | |
| def check_tag_exists(tag, repo): | |
| ecr_client = boto3.client('ecr', region_name='us-east-1') | |
| response = ecr_client.describe_images(repositoryName=repo, filter={'tagStatus': 'TAGGED'}) | |
| for i in response['imageDetails']: | |
| if tag in i['imageTags']: | |
| return True | |
| return False |
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
| package crypto | |
| import ( | |
| "crypto/sha256" | |
| ) | |
| // NewSHA256 ... | |
| func NewSHA256(data []byte) []byte { | |
| hash := sha256.Sum256(data) | |
| return hash[:] |
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
| # aws cloudformation deploy --template-file KeepDbStopped.yml --stack-name stop-db --capabilities CAPABILITY_IAM --parameter-overrides DB=arn:aws:rds:us-east-1:XXX:db:XXX | |
| Description: Automatically stop RDS instance every time it turns on due to exceeding the maximum allowed time being stopped | |
| Parameters: | |
| DB: | |
| Description: ARN of database that needs to be stopped | |
| Type: String | |
| AllowedPattern: arn:aws:rds:[a-z0-9\-]+:[0-9]+:db:[^:]* | |
| MaxStartupTime: | |
| Description: Maximum number of minutes to wait between database is automatically started and the time it's ready to be shut down. Extend this limit if your database takes a long time to boot up. | |
| Type: Number |
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 | |
| import sys | |
| import boto3 | |
| from botocore.exceptions import ClientError | |
| # -------------------------------------------------------------------- main --- | |
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
| Resources: | |
| RateLimitACL: | |
| Type: AWS::WAFv2::WebACL | |
| Properties: | |
| Name: rate-limit-acl | |
| Scope: REGIONAL | |
| Description: Auto-generated rate-limiting ACL. | |
| DefaultAction: | |
| Allow: {} | |
| VisibilityConfig: |
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
| #!/bin/sh | |
| # Make sure to: | |
| # 1) Name this file `backup.sh` and place it in /home/ubuntu | |
| # 2) Run sudo apt-get install awscli to install the AWSCLI | |
| # 3) Run aws configure (enter s3-authorized IAM user and specify region) | |
| # 4) Fill in DB host + name | |
| # 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket) | |
| # 6) Run chmod +x backup.sh | |
| # 7) Test it out via ./backup.sh |
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: Create a Volume from scratch and attach it to an instance. | |
| Metadata: | |
| AWS::CloudFormation::Interface: |
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" : "Single node MongoDB deployment with a RAID10 storage configuration", | |
| "Parameters" : { | |
| "KeyName" : { | |
| "Description" : "Name of an existing EC2 KeyPair to enable SSH access", | |
| "Type" : "String" | |
| }, |