Skip to content

Commit

Permalink
docs(workload-identity-samples): replaced project_id with project_num…
Browse files Browse the repository at this point in the history
…ber (GoogleCloudPlatform#7415)

* docs(workload-identity-samples): replaced project_id with project_number

* fixed copyright year

Co-authored-by: Dan Lee <[email protected]>
Co-authored-by: gcf-merge-on-green[bot] <60162190+gcf-merge-on-green[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <[email protected]>
  • Loading branch information
4 people authored Feb 7, 2022
1 parent 6cf3154 commit 3c7c26d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions iam/api-client/workload_identity_federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
from botocore.awsrequest import AWSRequest


def create_token_aws(project_id: str, pool_id: str, provider_id: str) -> None:
def create_token_aws(project_number: str, pool_id: str, provider_id: str) -> None:
# Prepare a GetCallerIdentity request.
request = AWSRequest(
method="POST",
url="https://sts.amazonaws.com/?Action=GetCallerIdentity&Version=2011-06-15",
headers={
"Host": "sts.amazonaws.com",
"x-goog-cloud-target-resource": f"//iam.googleapis.com/projects/{project_id}/locations/global/workloadIdentityPools/{pool_id}/providers/{provider_id}"
"x-goog-cloud-target-resource": f"//iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/providers/{provider_id}"
})

# Set the session credentials and Sign the request.
Expand All @@ -54,11 +54,12 @@ def create_token_aws(project_id: str, pool_id: str, provider_id: str) -> None:

def main():
# TODO(Developer): Replace the below credentials.
project_id = "my-project-id"
# project_number: Google Project number (not the project id)
project_number = "my-project-number"
pool_id = "my-pool-id"
provider_id = "my-provider-id"

create_token_aws(project_id, pool_id, provider_id)
create_token_aws(project_number, pool_id, provider_id)


if __name__ == "__main__":
Expand Down

0 comments on commit 3c7c26d

Please sign in to comment.