Skip to content

Instantly share code, notes, and snippets.

View jharrington22's full-sized avatar

James Harrington jharrington22

View GitHub Profile
@jharrington22
jharrington22 / gist:91a13d0a827540ea04cd32d58b7d8d4b
Created April 11, 2023 14:37
Create bucket and ACL in all regions
#!/bin/bash
REGIONS=$( aws ec2 describe-regions --region us-east-1 | jq -r '.Regions[] | select(.OptInStatus=="opt-in-not-required").RegionName' )
for region in ${REGIONS[*]}
do
echo $region
BUCKET_NAME="test-bucket-acl-$RANDOM"
echo "Bucket name: $BUCKET_NAME region: $region"
aws s3api create-bucket --bucket "test-acl-bucket-$RANDOM" --region "$region" --acl private --create-bucket-configuration LocationConstraint="$region"
apiVersion: cloudcredential.openshift.io/v1
kind: CredentialsRequest
metadata:
name: managed-velero-operator-iam-credentials-aws
namespace: openshift-velero
spec:
secretRef:
name: managed-velero-operator-iam-credentials
namespace: openshift-velero
providerSpec:
@jharrington22
jharrington22 / create-sts-cluster.sh
Last active May 12, 2021 19:06
Create STS cluster
#!/bin/bash
usage() {
cat <<EOF
usage: $0 [ OPTION ]
Options
-a AWS Account ID
-c Cluster name
-o OCP Version
-r AWS Region
#!/bin/bash
if [ -z "$1" ]; then
echo "$0 requires a prefix arg"
exit 1
fi
prefix=$1
#!/bin/bash
for id in $(cat reset-list-03-25-20); do
echo "Checking account $id"
AWS_ASSUME_ROLE=$(aws sts assume-role --role-arn arn:aws:iam::${id}:role/OrganizationAccountAccessRole --role-session-name SREAdminCreateUserJames --profile=osd-staging-1)
export AWS_ACCESS_KEY_ID=$(echo $AWS_ASSUME_ROLE | jq -r '.Credentials.AccessKeyId')
@jharrington22
jharrington22 / aws_terminate_ec2_instances.go
Created December 25, 2019 11:14
Find and terminate instances matching instance type and ami
package main
import (
"fmt"
"log"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
#!/bin/bash
for cluster in $(ocm cluster list --managed | awk '{print $2}' | grep -v NAME)
do
ocm cluster login "$cluster%" 2> /dev/null
if [ $? != 0 ]; then
echo -e "\n\nCouldn't log into $cluster\n\n"
continue
fi
oc delete ns openshift-dedicated-admin
@jharrington22
jharrington22 / get_aws_credentials.sh
Last active August 8, 2019 17:46
This script will get the AWS credentials for a given cluster using the AWS AccountClaim name. `source` it to set your AWS environment vars
#!/bin/bash
STS_SECRET_EXISTS=true
usage() {
cat <<EOF
usage: $0 [ OPTION ]
Options
-c AWS AccountClaim CR Name (AccountClaim Custom Resource Name)
-o Hive hostname
#!/bin/bash
# https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/
# Update status
# List cluster context names `kubectl config view -o jsonpath='{"Cluster name\tServer\n"}{range .clusters[*]}{.name}{"\t"}{.cluster.server}{"\n"}{end}'`
CLUSTER_NAME="192-168-99-100:8443"
APISERVER=$(kubectl config view -o jsonpath="{.clusters[?(@.name==\"$CLUSTER_NAME\")].cluster.server}")