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 / 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

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
@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,
"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 / gist:145a2ede6d9a6735bbaf97156f91abca
Created March 6, 2019 02:33
Enable powershell as default rdp shell
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -name Shell -Value 'PowerShell.exe -noExit'
@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()
@aws-scripting-guy
aws-scripting-guy / json-auth.md
Last active October 30, 2023 07:47
GitHub Actions Azure Service Connection (az ad sp create-for-rbac --name "myApp" --json-auth)
@aws-scripting-guy
aws-scripting-guy / azure-devops-predefined-variables-in-the-scripts.md
Last active May 6, 2024 14:05
Azure DevOps tips: Using predefined variables in the scripts

Azure DevOps Pipelines: How to access predefined variables from scripts

In this scenario we want to access predefined variable $Build.Reason from the PowerShell script. $Build.Reason will have different value based on what triggered the build.

Configure azure-pipelines.yml

Map $Build.Reason to env variable for the powershell script.

- powershell: |
 .\scripts\git-package.ps1
@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