# Connect Scaleway

Costfluent reads your Scaleway spend from Scaleway's billing API, with an API key you create for it
that may only read billing. One connection is one Scaleway organization, and the cost of every
project in it.

## How Costfluent connects

You give Costfluent the API key's secret key and your organization ID. Costfluent stores them
encrypted and uses the key for one read only: the organization's consumption, from Scaleway's billing
API, page by page. The organization identifies the connection, and the key is only ever used for that connection.

:::caution
Give the key the `BillingReadOnly` permission set alone. Costfluent's collector holds the key and
uses it on every sync, and Costfluent cannot see what else a Scaleway key may do, so it cannot
refuse a key with broader rights.
:::

## Prerequisites

1. The Owner or Integration owner organization role in Costfluent.
2. A Scaleway user who may create API keys for an IAM application: the organization's Owner, or a
   user with the `IAMManager` or `IAMApplicationManager` permission set.

## Connect

### Create the API key in Scaleway

<Stepper>

1. In the Scaleway console, under IAM, create an application for Costfluent.
2. Create a policy for that application with one rule, scoped to the organization, holding only the
   `BillingReadOnly` permission set ("List and read access to billing information").
3. Under IAM, API keys, generate an API key with the application as its bearer. Choose the longest
   expiry your organization allows: a key that expires stops the connection.
4. Copy the secret key. Scaleway shows it only once.
5. Copy your organization ID from the console's organization settings.

</Stepper>

### Connect in Costfluent

<Stepper>

1. Open **Settings**, then **Integrations**, select **Scaleway**, and open the **Connect** tab.
2. Keep the suggested **Display name** or enter your own, and paste the secret key and the
   organization ID into their fields.
3. Select "Test connection" to see each check, or "Connect" to save.

</Stepper>

Costfluent reads the organization's consumption with the key before storing anything, so a
connection that saves can read your cost. A key of another organization, or one that may not read
billing, is refused, and so is a connection with the same organization as an existing one.

## Data and freshness

Scaleway reports consumption per billing period, the UTC calendar month, not per day, so Costfluent
shows each project's cost for a month on the first day of that month. Month and longer views are
exact; a daily chart shows the whole month on its first day, and daily cost for Scaleway is not
available.

:::note
The running month is Scaleway's month to date. Each sync replaces it, so its cost grows during the
month until the month closes.
:::

:::note
Amounts are consumption before taxes and before discounts, so a month's total differs from its
Scaleway invoice by the taxes and discounts on it.
:::

Connecting imports as far back as your plan's backfill reaches, and at most six months
([Manage connections](/connect/manage-connections#how-it-behaves)), as long as Scaleway reports
consumption that far back.

## Reporting dimensions

- **Sub-account** is the Scaleway project's ID.
- **Service** is the Scaleway category the consumption is billed under, as the invoice groups it:
  Compute, Managed Databases, Observability and so on.
- **SKU** is Scaleway's SKU for what was billed, described by its product name.
- **Resource** is the resource name Scaleway states for the consumption.
- **Region** is the Scaleway region the SKU names (Paris, Amsterdam, Warsaw or Milan), with its
  availability zone where the SKU names one. A global resource, such as a reserved IP, has none.
- The billing account is the Scaleway organization, and the billing period is the calendar month.

## Update or disconnect

### After connecting

The **Manage** tab lists the connection by its display name, with its Scaleway organization. Open
the gear icon beside it to see whether the costs are still readable, which workspaces the connection
feeds, and which months have been imported. **Run checks** runs the checks again on request.

### Rotating or removing access

Scaleway does not rotate the key for you. Before it expires, create a new API key the same way,
select **Update credentials** on the connection page and paste it; then delete the old key in IAM,
under API keys. A key of another organization is refused.

To retire the connection, remove it in Costfluent and delete its API key in IAM. Removing it erases
the cost it imported ([Remove a connection](/connect/manage-connections#remove-a-connection)).

## Troubleshooting

- **Scaleway refused this secret key.** The secret key is wrong, or the key was deleted or has
  expired. Scaleway shows a secret key only once, so create a new key if you no longer have it.
- **This key may not read the billing of organization …** The application has no policy rule
  granting `BillingReadOnly` on the organization, or the organization ID is of another organization
  than the key. Check the policy, and copy the organization ID again from the organization settings.
- **A Scaleway organization ID is a UUID.** What was pasted is not an organization ID, for example
  the access key, which starts with `SCW`. Copy the organization ID from the organization settings.
- **This key belongs to another organization.** Shown when updating credentials: the new key and
  organization ID are not those of the organization this connection collects. Connect that
  organization as a new connection.
