Skip to main content

Connect your AWS account

As an organization owner, you connect an AWS account to Multicloud. You download multicloud.tf, and you run terraform apply. Then the Console shows the account as verified, and your pools can run in it. It takes about five minutes.

There are two ways:

  • Create a new AWS account (recommended, the default). The file creates a new AWS account only for Multicloud in your AWS Organizations, then connects it. You need sign-in to the management account of your AWS Organizations.
  • Use an AWS account you have. You give the 12-digit ID of an account you made yourself, and the file connects it.

Multicloud uses an IAM role in your account. Multicloud never asks for, and never stores, an access key. You keep the account, the bill and the quota. Nothing changes in AWS until you run Terraform yourself.

What Multicloud can do in your account

Everything below applies to the one AWS account that you connect, and only to it. Multicloud has no access to your other AWS accounts.

  • It can read the details of the machines and networks in the account (EC2), including a machine's startup log.
  • It can create, change and delete only the machines and network parts that it marks as its own (tag multicloud:managed=true).
  • It can ask AWS for more machine capacity (EC2 quota).
  • It has no access to your files (S3), your databases or your users (IAM).
  • There is no password and no access key. Only Multicloud can use the role, one hour at a time.

When you run Terraform, it also creates up to three standard AWS service roles that EC2 Spot, EC2 Fleet and Service Quotas need, if your account does not have them yet. Terraform creates them with your credentials. Multicloud cannot change them.

You can remove the access at any time: delete your pools first, then click Disconnect on the account. See Disconnect an account. The exact permissions are in the public module source, github.com/multicloud/terraform-aws-multicloud.

Want a second opinion? In the Console, click Copy the question next to the download. Paste it into any AI assistant, such as ChatGPT, Claude or Gemini. It holds the file and a question, and the assistant explains the file and the permissions in plain words. The file holds no token, so nothing secret leaves the page.

Why a separate AWS account

We recommend an AWS account that holds only Multicloud resources:

  • Multicloud then sees only its own machines, never your other work.
  • Your AWS bill shows the Multicloud costs on their own.
  • To remove everything, you close that one account.

Create a new AWS account in the Console does this for you. If your company does not use AWS Organizations, create the account yourself, then choose Use an AWS account I have:

  • If your company uses AWS Organizations: sign in to the main account, open AWS Organizations, click Add an AWS account, then Create an AWS account. Give it a name such as "multicloud" and an email address. AWS creates it in a few minutes. See the AWS guide.
  • If not: sign up for a new AWS account with another email address.

Then connect the new account, and run Terraform with credentials for that account. Not sure how? In the Console, open How do I create a separate AWS account? and click Copy the question. Paste it into any AI assistant, and it guides you step by step.

What you need

  • You are an owner of the organization. Members can see the accounts, but they cannot connect one.
  • Terraform or OpenTofu installed on your computer. Install pages: Terraform, OpenTofu. Every command on this page works with tofu in place of terraform.
  • A terminal on macOS or Linux. On Windows, use WSL.
  • AWS credentials. Terraform uses them on your computer. Multicloud never sees them.
    • New account: credentials of the management account of your AWS Organizations. Multicloud gets no access to the management account.
    • An account you have: credentials that can create IAM roles in that account.
  • New account: an email address that no other AWS account uses. A plus address such as you+multicloud@company.com usually works. The email stays in your browser and in your files. Multicloud does not store it.
  • An account you have: its 12-digit ID. There are two ways to find it:
    • In the AWS console, click your account name at the top right. The menu shows the Account ID.

    • Or run this command with credentials for the account you connect. It prints the account of those credentials:

      aws sts get-caller-identity --query Account --output text
      

Connect a new AWS account

  1. In the Console, open Organization → Cloud accounts.

  2. Click Connect a cloud, then Connect an AWS account.

  3. Keep Create a new AWS account selected.

  4. Enter the email of the new AWS account, and type it again. A typo makes an AWS account with the wrong email.

  5. Click Continue.

  6. Click Download multicloud.tf and Download multicloud.auto.tfvars. Save both files in a new, empty folder. multicloud.auto.tfvars holds the email only. If your browser renames a file, rename it back.

  7. Give Terraform the connect token, as in step 6 of Connect an AWS account you have.

  8. In the same terminal window, with the credentials of your management account, run the two commands in this order:

    terraform init && terraform apply -target=module.multicloud_account
    terraform apply
    

    The first command creates the new AWS account. AWS takes a few minutes. Terraform warns that -target is for exceptional cases: that is expected here. The second command creates the Multicloud role in the new account. Each time, Terraform asks you to confirm: type yes and press Enter.

  9. Keep the Console page open. When the second apply finishes, the page updates by itself.

The list shows New account in place of the account ID until Terraform has created the account. If you get a new connect token later, keep multicloud.auto.tfvars in the folder. Without it, Terraform asks for var.multicloud_account_email.

Connect an AWS account you have

  1. In the Console, open Organization → Cloud accounts.

  2. Click Connect a cloud, then Connect an AWS account.

  3. Select Use an AWS account I have, and enter the AWS account ID.

  4. Click Continue.

    The account reaches every AWS region. You choose the regions of each pool later, in the pool's Settings tab.

  5. Click Download multicloud.tf. Save the file in a new, empty folder. It holds no password and no key. If your browser renames it, rename it back to multicloud.tf.

  6. Copy the connect token. Then open a terminal in that folder, run this command, paste the token and press Enter:

    read -rs TF_VAR_multicloud_connect_token && export TF_VAR_multicloud_connect_token
    

    Nothing shows while you paste: the shell hides the token. That is normal. The shell does not keep it in its history. Use the same terminal window for the next step. Another terminal window does not have the token. If Terraform asks for var.multicloud_connect_token, paste the token there.

  7. In the same terminal window, run:

    terraform init && terraform apply
    

    Terraform shows what it will create and asks you to confirm: type yes and press Enter. With OpenTofu, run tofu init && tofu apply.

  8. Keep the Console page open. When the apply finishes, Terraform tells Multicloud about the role, and the page updates by itself.

The connect token is shown once. It works for one connect, until the time the page shows. Do not save it in a file. multicloud.tf holds no secret.

Wait for the check

After the apply, Multicloud checks the role.

  • Waiting for terraform apply: Multicloud has not heard from Terraform yet. Run the apply, or wait for it to finish.
  • Waiting for AWS: Terraform created the role, but AWS has not made it work in every region yet. A new IAM role can take a few minutes. This is normal, not an error. For about 15 minutes the page checks again every 30 seconds. You can also click Verify now.
  • Verified: Multicloud can start machines in this account. Create a pool to use it.

When the account is verified, Multicloud reads the spot capacity limits (quotas) of the account. Multicloud asks AWS for more spot quota only when you allow it. To allow it, select Get enough capacity when you connect the account, or later on the account page. Only an organization owner can allow it, and you can turn it off again at any time. Without it, the page shows each quota that is too low and the value Multicloud would ask for. Multicloud asks AWS for nothing. If AWS refuses a request, the page shows the refused quota, also after you reload it. Pools can still run, with less capacity. You can ask AWS for the quota in the Service Quotas console.

Account status

Status What it means What to do
Pending The account waits for terraform apply or for AWS. Run the apply, then wait a few minutes.
Token expired The connect token expired before Terraform used it. Click New connect token in the list, then run the apply again.
Verified Multicloud can use the role. Nothing.
Degraded Multicloud cannot use the role fully. Read the reason in Last check, run the apply again, then click Verify now.
Revoking Access to the account is being removed. Wait.
Revoked An organization owner disconnected the account. Multicloud no longer uses it. Remove the role with Terraform (see Disconnect an account). To use the account again, connect it again.

If something goes wrong

  • The check failed. The page shows the reason. Fix what the reason names, run terraform apply again in the same folder, then click Verify now.
  • The token expired, or you closed the page before the apply. Click New connect token on the account in the list. The old token stops working. Run the apply again with the new token.
  • Terraform asks for var.multicloud_connect_token. The token command ran in another terminal window, or did not run. Paste the token at the prompt, or run the token command in this window and run the apply again.
  • The apply stops with "already exists" for a service-linked role. Another Multicloud folder in this AWS account created the role, or the folder that created it lost its Terraform state.
    • The role came from another folder that used module 1.1.0 or older: run terraform apply in that folder first, with module 1.1.1 or later. Then run the apply in this folder again.
    • You lost the state of the folder that created the role, and no other folder holds the role: in the IAM console, open the role and change its description to any other text. Then run the apply again. Do not do this while a folder still holds the role in its state. The next plan in that folder then shows a destroy of the role, and an apply deletes it. If you see that destroy, do not apply. Change the description back to the text it had, then plan again.
    • Do not set manage_service_linked_roles = false to get past this error. With false, the module creates none of the three roles, and spot machines cannot start in an account without the EC2 Spot role. In a folder whose state already holds the roles, false also plans to destroy them.
  • This AWS account is already connected to a Multicloud organization. One AWS account belongs to one organization. Use the organization that already has it, or connect another account.
  • Your organization has not passed the payment gate. Open Billing and follow the steps there.

Command line

The mctl cloud-account commands do the same steps from a terminal. mctl cloud-account create writes the same multicloud.tf that the Console downloads. For a new account: mctl cloud-account create --cloud AWS --new-account-email you+multicloud@company.com, then mctl cloud-account apply <id>. It runs both stages. To disconnect: mctl cloud-account disconnect <id>. mctl cloud-account show <id> also lists the refused quota and whether quota requests are allowed. To allow quota requests: mctl cloud-account allow-quota-requests <id>. To stop them: mctl cloud-account revoke-quota-requests <id>.

Disconnect an account

An organization owner can disconnect an account. Multicloud then stops using it at once. You cannot undo a disconnect, but you can connect the same account again later.

  1. Delete the pools that use the account. Wait a few minutes until their machines are gone.

  2. In Cloud accounts, click Disconnect on the account. Type the account ID to confirm, then click Disconnect AWS account.

    If a pool still uses the account, nothing changes. The page names the pools. Delete them, then try again.

  3. Remove the Multicloud role from the account. In the folder with multicloud.tf:

    • New account (Terraform created it): run mctl cloud-account destroy <id>. It removes the role and closes the AWS account. AWS keeps a closed account for 90 days, and its email cannot be used for a new AWS account again.
    • An account you have: run tofu destroy (or terraform destroy). This deletes the role.

The disconnect needs your sign-in. An API key cannot disconnect an account. The disconnect deletes nothing in your AWS account. Networks that Multicloud made for your pools can stay in the account; you may delete them in the AWS console. They carry the tag multicloud:managed=true.

The destroy can stop with "Service-linked role can't be deleted because there are pending service limit increase request(s)". AWS keeps the Service Quotas role while a quota request is open. The access is already removed at that point. Keep the folder. After AWS closes the requests (AWS console, Service Quotas, Quota request history), run terraform destroy again in the same folder.