Skip to content

Instantly share code, notes, and snippets.

View jespereneberg's full-sized avatar
💪
I may be slow to respond.

Jesper Eneberg jespereneberg

💪
I may be slow to respond.
View GitHub Profile
@jespereneberg
jespereneberg / 1 - Use profile (Preferred)
Last active January 31, 2023 23:54
docker compose ecs context with AWS SSO
# This is, in my opinion, the preferred way to solve this since you can have several context pointing to different accounts/environments. See: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sourcing-external.html and https://github.com/linaro-its/aws2-wrap#use-the-credentials-via-awsconfig
# Uses a credential_process profile in your .aws/config file. It's this profile you will use when setting up the docker compose ecs context as the credentials_process looks up the needed credentials.
$ cat ~/.aws/config
[profile account1]
sso_start_url = https://d-123456789.awsapps.com/start#/
sso_region = us-east-1
sso_account_id = 123
sso_role_name = AdministratorAccess
region = eu-north-1
@jespereneberg
jespereneberg / KMSKeyPolicy.json
Created February 16, 2021 22:41 — forked from duttonw/KMSKeyPolicy.json
KMS policy for cross account org usage
{
"Version": "2012-10-17",
"Id": "key-consolepolicy-4",
"Statement": [
{
"Sid": "Enable IAM User Permissions",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::${AWS::AccountId}:root"
},
@jespereneberg
jespereneberg / One import via join.yaml
Last active May 25, 2020 09:31
Fn::ImportValue from other stacks
Tags:
- Key: Name
Value:
!Join ['_', [ ec2, "Fn::ImportValue" : {"Fn::Sub":'${BaseStackName}-Environment'}, test2]]
#This will create a name tag with value: ec2_<yourValueFromOtherStack>_test2
@jespereneberg
jespereneberg / s3-to-es-lamba.py
Created November 18, 2016 22:54 — forked from s-fujimoto/s3-to-es-lamba.py
Import Elasticsearch from ELB access log for AWS Lambda Function
##################################################
### Elasticsearch host name
ES_HOST = "search-******************.ap-northeast-1.es.amazonaws.com"
### Elasticsearch prefix for index name
INDEX_PREFIX = "awslogs"
#################################################
### ELB access log format keys
ELB_KEYS = ["timestamp", "elb", "client_ip", "client_port", "backend_ip", "backend_port", "request_processing_time", "backend_processing_time", "response_processing_time", "elb_status_code", "backend_status_code", "received_bytes", "sent_bytes", "request_method", "request_url", "request_version", "user_agent"]