Do not trust anyone! (in the cloud)

  Рет қаралды 48

DevOps Undefined

DevOps Undefined

Күн бұрын

Workload Identity explained! How it works in the major Cloud Providers and CI/CD services?
How to securely issue temporary AWS (Amazon Web Services) credentials for applications that run on Google Cloud Platform (GCP)?
#GCP #AWS #WorkloadIdentity #CloudTrust #idToken
GCP VM identity authentication flow for AWS services
Prerequests
GCP
1.1 Service Account in GCP(optional): cloud.google.com/iam/docs/ser...
The default service account is used in the example below. If you create a custom account, just replace the name "default" below
1.2 Virtual Machine in GCP: cloud.google.com/compute/docs...
1.4 Assign the previosly created GCP service account to the VM: cloud.google.com/compute/docs...
1.3 AWS CLI installed in the GCP VM: docs.aws.amazon.com/cli/lates...
1.4 Issue a GCP idToken from the GCP VM to get the AUTHORIZED_PARTY and SUBJECT encoded in the token:
curl -H "Metadata-Flavor: Google" \
'metadata/computeMetadata/v1/instance/service-accounts/default/identity?audience=AUDIENCE'
Note: audience uri parameter can be set to a custom value. Just make sure to use one and the same value here and in 2.1
You can check the generated token payload by pasting it in jwt.io
AWS
2.1 Create IAM identity role for OpenID Connect Federaion: docs.aws.amazon.com/IAM/lates...
with the following statement:
{
"Effect": "Allow",
"Principal": {"Federated": "accounts.google.com"},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"accounts.google.com:aud": "azp-value-from-the-token-payload",
"accounts.google.com:oaud": "AUDIENCE",
"accounts.google.com:sub": "sub-value-from-the token-payload"
}
}
}
and attach an AWS IAM policy to the created role to allow access to specicific AWS resources: docs.aws.amazon.com/IAM/lates...
Note: { and } symbols should be replaced with the ASCII equivalents.
Note: "azp-value-from-the-token-payload" and "sub-value-from-the-token-payload" should be replaced with the values from the generated token payload
The "StringEquals" conditions ensure that the defined IAM role can be assumed only by the intended GCP service account.
Note: AUDIENCE string can be set to a custom value. Just make sure to use one and the same value in 1.4 and 2.1
Authentication workflow
From the GCP Virtual Machine:
Construct role name
ROLE_ARN="arn:aws:iam::"your_aws_account_id":role/your_aws_role_name"
Note: "your_aws_account_id" and "your_aws_role_name" should be replaced with the AWS Account ID and AWS role name created in 2.1
Generate GCP Identity Token
jwt_token=$(curl -sH "Metadata-Flavor: Google" "metadata/computeMetadata/v1/instance/service-accounts/default/identity?audience=AUDIENCE&format=full&licenses=FALSE")
Get the "sub" claim from the token. First split the token using dot as separator, then get the second part(the payload), do a base64 decode and get the value of "sub" key
jwt_sub=$(jq -R 'split(".") | .[1] | @base64d | fromjson' ❮❮❮ "$jwt_token" | jq -r '.sub')
Note: replace "[" and "]" symbols with the ascii alternatives
Note: replace "❮" symbol with the ascii alternative
Call the AssumeRoleWithWebIdentity API to request AWS temporary credentials
credentials=$(aws sts assume-role-with-web-identity --role-arn $ROLE_ARN --role-session-name $jwt_sub --web-identity-token $jwt_token | jq '.Credentials' | jq '.Version=1')
Print credentials
echo $credentials
The returned AWS credential format is:
{
"Version": 1,
"AccessKeyId": "xxxxxxxx",
"SecretAccessKey": "xxxxxxxx",
"SessionToken": "xxxxxxxx",
"Expiration": "xxxxxxxx"
}
00:00 - Intro
00:05 - What is trust
00:18 - Workload Identity
00:32 - Basic trust concept
01:02 - Use GCP Metadata service to create a signed idToken
01:22 - Call the AssumeRoleWithWebIdentity API to request AWS temporary credentials
01:40 - OpenID Connect based trust in all major cloud providers

Пікірлер
Create linux systemd-based useless machine!
4:57
DevOps Undefined
Рет қаралды 182
GUADEC 2024 - Day 1, track 2
5:37:27
GNOME
Рет қаралды 1,1 М.
WHAT’S THAT?
00:27
Natan por Aí
Рет қаралды 13 МЛН
Looks realistic #tiktok
00:22
Анастасия Тарасова
Рет қаралды 105 МЛН
THEY made a RAINBOW M&M 🤩😳 LeoNata family #shorts
00:49
LeoNata Family
Рет қаралды 43 МЛН
Proxmox Create a Firewall Rule Template
10:18
Liv4IT
Рет қаралды 490
We Need to Rethink Exercise - The Workout Paradox
12:00
Kurzgesagt – In a Nutshell
Рет қаралды 4,5 МЛН
AWS IAM Core Concepts You NEED to Know
21:40
Be A Better Dev
Рет қаралды 198 М.
FIDO Promises a Life Without Passwords
9:58
IBM Technology
Рет қаралды 398 М.
Google Releases AI AGENT BUILDER! 🤖 Worth The Wait?
34:21
Matthew Berman
Рет қаралды 226 М.
Introduction to Gitlab - Beginner Tutorial
42:08
WemaDevOps
Рет қаралды 2,8 М.
The cloud is over-engineered and overpriced (no music)
14:39
Tom Delalande
Рет қаралды 504 М.
Generative AI in a Nutshell - how to survive and thrive in the age of AI
17:57
How I Would Learn AWS Today (after 10 years of cloud experience)
40:28
Be A Better Dev
Рет қаралды 377 М.
Это Xiaomi Su7 Max 🤯 #xiaomi #su7max
1:01
Tynalieff Shorts
Рет қаралды 1,7 МЛН
АЙФОН 20 С ФУНКЦИЕЙ ВИДЕНИЯ ОГНЯ
0:59
КиноХост
Рет қаралды 1,1 МЛН
КРУТОЙ ТЕЛЕФОН
0:16
KINO KAIF
Рет қаралды 6 МЛН
Это - iPhone 16 и вот что надо знать...
17:20
Overtake lab
Рет қаралды 114 М.
Какой ноутбук взять для учёбы? #msi #rtx4090 #laptop #юмор #игровой #apple #shorts
0:18