Create a lambda with these two files
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
ECR_REG=12345678910.dkr.ecr.us-west-2.amazonaws.com | |
ECR_REPO=my_app | |
ECR_TAG=tag_name | |
RUN_NAME=${ECR_REPO}_new | |
# login to ECR | |
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin $ECR_REG | |
# Start container | |
docker run --detach --name $RUN_NAME $ECR_REG/$ECR_REPO:$ECR_TAG tail -f /dev/null |
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 shapely.wkt | |
#wkt = 'POLYGON ((-164.488235 53.59074, -163.863495 55.320713, -167.797485 55.721722, -168.259628 53.987499, -164.488235 53.59074))' | |
wkt = 'POLYGON ((-166.071014 55.533596, -165.424973 53.755867, -161.644806 54.152309, -162.122131 55.934521, -166.071014 55.533596))' | |
# Load polygon and order the points by LATITUDE | |
poly = shapely.wkt.loads(wkt) | |
points = poly.exterior.coords[:4] | |
points.sort(key = lambda x: x[1]) |
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 base64 | |
import logging | |
import json | |
from urllib import request | |
from urllib.request import Request, urlopen | |
from urllib.parse import urlencode | |
from urllib.error import HTTPError | |
from http import cookiejar | |
from remotezip import RemoteZip |
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
# Stupid CloudFormation doesn't support this right now | |
TeaStackName=<TEA>-UAT-TEA | |
TeaLambdaName=$(aws cloudformation describe-stacks --query "Stacks[?StackName=='$TeaStackName'].Outputs" | jq -r '.[][] | select ( .OutputKey == "EgressLambdaName" ).OutputValue') | |
TeaLambdaLogFileName=$(echo -n "/aws/lambda/$TeaLambdaName") | |
dimensions='dimensions={service=$.message.timing.service}' | |
transformation=$(echo metricName=duration,metricNamespace=TEA,metricValue='$.message.timing.duration',$dimensions,unit=Milliseconds) | |
aws logs put-metric-filter \ | |
--log-group-name $TeaLambdaLogFileName \ |
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 time | |
import json | |
import argparse | |
from urllib.parse import urlencode | |
from urllib.request import Request, urlopen | |
from statistics import mean | |
from random import randrange | |
MIN_DELAY=0.5 |
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 logging | |
import statistics | |
from math import sqrt | |
from shapely import wkt | |
from shapely.ops import linemerge, unary_union, polygonize | |
from shapely.geometry import Polygon | |
# Move the box out of earth coordinate system | |
def shift_polygon(bbox): |
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
# Upload your key to NGAP Bastion Self-serve bucket | |
# https://wiki.earthdata.nasa.gov/display/ESKB/SSH+Bastion+Key+Upload+-+Self-Service | |
export key_bucket=$(aws s3 ls | xargs -n1 echo | grep ngap-bastion-authorized-public-keys) | |
export my_ssh_key="/path/to/.ssh/<your_private_key>" | |
aws s3 cp $my_ssh_key.pub s3://$key_bucket/ | |
# Optional Params with Reasonable Defaults that you may want to change | |
export bastion_name="SSM Bastion" | |
export instance_type="t2.micro" |
NewerOlder