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
Try this - it requires that you have the AWS command line tools installed and that your instance has either been assigned an IAM role with sufficent permissions, or that your AWS command line tools have been set up with the right credentials. You should use IAM roles if you want to get this info at first boot, which I suspect is what you want to use this for? | |
aws ec2 describe-instances --region eu-west-1 --output text --instance-ids `curl -s http://169.254.169.254/latest/meta-data/instance-id` | grep TAGS | |
If you create an IAM role called AllowDescribeInstances with the following policy this and assign it to your instances, this is the minimum permissions set that is required. | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ |
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
# Run this Lambda function inside a VPC with a MongoDB instance inside it. | |
# Set up security groups to allow the function to communicate with the MongoDB endpoint | |
# NAT service or NAT instance is required because the function need to access AWS KMS, which an external endpoint | |
# Set four environment variables for the function containing the details required for the MongoDB endpoint uri | |
# I used the Bitnami MongoDB install from the AWS Marketplace | |
import boto3 | |
import os | |
from base64 import b64decode |
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 requests_oauthlib import OAuth1Session | |
import os | |
CONSUMER_KEY = os.getenv("CONSUMER_KEY") | |
CONSUMER_SECRET = os.getenv("CONSUMER_SECRET") | |
ACCESS_KEY = os.getenv("ACCESS_KEY") | |
ACCESS_SECRET = os.getenv("ACCESS_SECRET") | |
twitter = OAuth1Session( | |
CONSUMER_KEY, | |
client_secret=CONSUMER_SECRET, |
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
{ | |
"executionRoleArn": "arn:aws:iam::<<ACCOUNT_NUMBER>>:role/ecsTaskExecutionRole", | |
"containerDefinitions": [ | |
{ | |
"dnsSearchDomains": null, | |
"logConfiguration": { | |
"logDriver": "awslogs", | |
"options": { | |
"awslogs-group": "/ecs/es-proxy", | |
"awslogs-region": "us-east-1", |