Skip to content

Instantly share code, notes, and snippets.

#list projects
gcloud projects list
#list VMs
gcloud --project [project-id] compute instances list
#List Cloud Run services
gcloud --project [project-id] run services list
#Lookup GCP secret
@kevinhooke
kevinhooke / gist:c6931622b2b0ef15d962bb9f43b0d3cf
Created October 31, 2024 17:29
curl with basic auth, show headers
#show response headers
curl -I some-url
#with basic auth
curl -u 'userid:password' some-url
@kevinhooke
kevinhooke / gist:1091aac6844e4ec7fd4bc419ce0bd8dd
Created October 18, 2024 10:20
git delete/reset last local commit
git reset HEAD~
@kevinhooke
kevinhooke / gist:fb73449c17084b3cb676521300af8525
Created October 7, 2024 12:26
aws cli how to find what CloudFormation stack a resource is part of
aws cloudformation describe-stack-resources --physical-resource-id example-s3-bucketname
# Heading 1
## Heading 2
### Heading 3
# Tables
| a | b |
|---|---|
|aaa|bbb|
# Lists
@kevinhooke
kevinhooke / gist:d2f71ddfe938c9fa8a95a918d8f5ba4e
Created February 17, 2023 19:56
AWS CloudFormation template for an IAM role
Resources:
roleResourceName:
Type: AWS::IAM::Role
Properties:
RoleName: role-name
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
@kevinhooke
kevinhooke / gist:cffa89efd51b074f8b9162c0a7c8ff4c
Created November 17, 2022 22:11
AWS SDK Lambda invokAsync
If you call lambda.invokeAsync() from one lambda calling another, if the calling lambda completes/exits before the second
lambda has been successfully invoked then depending on the timing it's possible the second Lambda will not invoke sucessfully.
The SDK docs show calling invokeAsync with a callback:
const params = {
"FunctionName": "fucntion-name-to-invoke",
"InvokeArgs": JSON.stringify(payload-to-pass-to-lambda)
};
lambda.invokeAsync(params, function (error, result) {
@kevinhooke
kevinhooke / gist:9c84601f7e42a7d9666d35b76ac3e1f0
Created May 17, 2022 18:06
CloudWatch Insights query examples
fields @timestamp, @message
| filter @message like /string pattern to match/
| sort @timestamp asc
fields @timestamp
| filter @message like /string pattern to match/
#parse line, match a pattern, capture pattern match in this case * as named value userId
| parse "\"userId\": \"*\"" as userId
#only include where this has a value
@kevinhooke
kevinhooke / gist:f2b59f5e3240f99852c806d3451728f7
Created March 1, 2022 19:00
aws cli list lambdas by name using query
#list-functions is paginated by default so need to set page-size, no-paginate or simiilar to get complete list
# see https://docs.aws.amazon.com/cli/latest/reference/lambda/list-functions.html
# https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-pagination.html
aws lambda list-functions --region us-west-2
--query 'Functions[?starts_with(FunctionName, `name-pattern-here`) == `true`].FunctionName'
--page-size 300 >> output.txt
@kevinhooke
kevinhooke / gist:fe4bbcdfdb3080c56bd79637bb37f09f
Created January 20, 2022 00:57
AWS API Gateway 403 "MIssing authentication token"
Calling an api that doesn't exist in your API Gateway will return a 403 with the rather misleading response:
{
"message": "Missing Authentication Token"
}