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

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

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