Skip to content

Instantly share code, notes, and snippets.

View aws-scripting-guy's full-sized avatar

AWS Scripting Guy aws-scripting-guy

View GitHub Profile
@aws-scripting-guy
aws-scripting-guy / tasks.json
Last active May 28, 2018 12:38
CloudFormation template validation in Visual Studio Code
// requirements
// aws cli has to be installed
// working AWS credentials file ~/.aws/credentials
// copy this file as tasks.json under the .vscode directory in your templates project directory
// open your CloudFormation template and hit Ctrl + Shift + B
{
"version": "0.1.0",
"command": "aws",
"isShellCommand": true,
@aws-scripting-guy
aws-scripting-guy / aws-cli_file _uri _descriptor.ps1
Created March 4, 2016 23:39
aws cli file:// URI descriptor - call parent directory
# PowerShell
$regions = "eu-west-1"
foreach ($region in $regions) {
aws cloudformation create-stack `
--parameters file://$PWD\..\templates\stack_parameters.json `
--tags file://$PWD\..\templates\stack_tags.json `
--stack-policy-body file://$PWD\..\templates\stack_policy.json `
--template-body file://$PWD\..\templates\log_bucket_template.json `
@aws-scripting-guy
aws-scripting-guy / array_as_param.ps1
Created March 6, 2016 21:55
powershell script - array as param
Param(
[array]$region = @( "eu-west-1")
)
foreach ($item in $region) {
echo $item
}
#PS> .\array_as_param.ps1 us-east-1,eu-west-1
@aws-scripting-guy
aws-scripting-guy / get_account_id_lambda.py
Created March 6, 2016 23:49
Get AWS account id inside Lambda function programmatically - python
def lambda_handler(event, context):
# Get Account Id from lambda function arn
print "lambda arn: " + context.invoked_function_arn
# Get Account ID from lambda function arn in the context
ACCOUNT_ID = context.invoked_function_arn.split(":")[4]
print "Account ID=" + ACCOUNT_ID
@aws-scripting-guy
aws-scripting-guy / vs_code_behind_proxy
Created March 7, 2016 13:35
Visual Studio Code - working with git behind proxy
git config --global http.proxy http://myproxyserver:8080
@aws-scripting-guy
aws-scripting-guy / gist:884ffa9d44bd14f7493a670543284552
Created April 2, 2016 18:33
AWS EC2 metadata. Check attached IAM role from EC2 instance. Get temporary credentials.
# Get IAM Role name from Instance Profile Id
curl http://169.254.169.254/latest/meta-data/iam/info
# Get credentials
curl http://169.254.169.254/latest/meta-data/iam/security-credentials/<role-name>
# More info
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
@aws-scripting-guy
aws-scripting-guy / boto3_set_HTTPS_PROXY..py
Created April 3, 2016 21:08
boto3 set HTTPS_PROXY environment variable directly in python script
# Works both with IDLE and PTVS for Visual Studio
import os
import boto3
os.environ['HTTPS_PROXY'] = '<proxyurl>:<port>'
s3 = boto3.client('s3')
s3.list_buckets()
"s3:DeleteReplicationConfiguration"
does not work in bucket policies
s3:GetObjectVersion
means tha you will actually GET OBJECT = one of the object's version.
@aws-scripting-guy
aws-scripting-guy / readme.md
Last active October 16, 2022 21:20
Setting up PowerShell as default terminal in Visual Studio Code (Windows and Mac OS)
  1. Open VS Code
  2. Ctrl + Shift + P
  3. Type "user"
  4. Choose "Preferences: Open user Settings"
  5. Include following settings and restart
  6. Test Terminal by Ctrl + Shift + (Command +)

Mac OS

Simplest way to enable global node modules on MacOS

Get default npm modules path

$ npm config list | grep prefix
prefix = "/usr/local/Cellar/node/7.10.0/libexec/npm"

Update PATH with default modules dir

export PATH=/usr/local/Cellar/node/7.10.0/libexec/npm/bin:$PATH