Accessing AWS CUR Data with Google Workload Identity Federation
Kubecost allows for access to an AWS Cost and Usage Report (CUR) without any Elastic Kubernetes Service (EKS) clusters in AWS by using GCP's Workload Identity Federation. This doc will show you how to configure Workload Identity and connect it to your AWS account.
Prerequisites
AWS service requirements
Before starting this tutorial, you need to configure a CUR in AWS that is integrated with Athena. Follow 'Step 1: Setting up a CUR' and 'Step 2: Setting up Athena' in our AWS Cloud Integration doc, then return here. Because you are not following the rest of the tutorial, you will not need to download any files from our poc-common-configurations GitHub repository linked at the start of the tutorial. The details of your Athena configuration will be used later when creating the cloud integration and secret.
You will also need access to the AWS Management Account for your organization.
GCP service requirements
These steps are written using gcloud CLI commands. If you wish to perform these steps in your console, you will need gcloud CLI.
You will also need Kubecost installed on at least one GCP cluster. You will be required to provide the name and zone of this cluster.
Overview
Step 1: Enabling GCP metadata server
This should be enabled by default. If not, run this command:
Step 2: Creating a GCP service account:
In the GCP account in which your Kubecost cluster exists, create a GCP service account to bind to the Kubecost cloud-cost container pod using Workload Identity:
Add the permissions required for Workload Identity Federation:
[kubecost/kubecost-sa]
can be replaced with whatever [/] as desired, if the config above is modified.
Allow the service account to generate OIDC ID tokens for authentication with AWS:
Step 3: Create a Kubernetes service account for Kubecost
Use the following manifest:
Step 4: Create a payer account in AWS with IAM access
From your AWS management account:
Access the IAM Dashboard, then select Roles in the left navigation.
Select Create Role.
For 'Trusted entity type', select Web identity.
For 'Web identity', in the 'Identity provider' dropdown, select Google.
In the 'Audience' box, select the unique service account ID for the
kubecost-aws-cur-role
, then select Next.Add CUR access permissions, then select Next.
Review the details for your role for accuracy, then select Create role.
Step 5: Integrate AWS with Kubecost
Create a cloud-integration.json
file and provide the following values (see below for explanations of these values):
The aud
parameter should match the value for 'Audience' you probided in Step 4.5 (the unique service account ID for the kubecost-aws-cur-role
). roleARN
should be the ARN of the role created with that audience in Step 4.
Next, create a secret from your cloud-integration.json
:
Step 6: Install/upgrade Kubecost with service account and integration config
Run the following command with the appropriate service account and integration values:
Last updated