Multi-Account Setups
Using LocalStack in multi-tenant setups
less than a minute
Note
Please note that multi-accounts may not work for use-cases that have cross-account and cross-service access. See this issue for more information.LocalStack ships with multi-account support which allows namespacing based on AWS account ID.
LocalStack uses the value in the AWS Access Key ID field for the purpose of namespacing over account ID. For more information, see Credentials.
The Access Key ID field can be configured in the AWS CLI in multiple ways: please refer to AWS CLI documentation.
Examples
In following examples, we configure the AWS CLI account ID via environment variable.
$ AWS_ACCESS_KEY_ID=000000000001 awslocal ec2 create-key-pair --key-name green-hospital
$ AWS_ACCESS_KEY_ID=000000000002 awslocal ec2 create-key-pair --key-name red-medicine
$ AWS_ACCESS_KEY_ID=000000000001 awslocal ec2 describe-key-pairs
{
"KeyPairs": [
{
"KeyFingerprint": "6b:e3:a3:41:4b:60:f3:6d:7b:84:3e:17:e3:ad:d0:15",
"KeyName": "green-hospital"
}
]
}
$ AWS_ACCESS_KEY_ID=000000000002 awslocal ec2 describe-key-pairs
{
"KeyPairs": [
{
"KeyFingerprint": "16:4c:64:13:36:41:7c:75:d0:51:f0:db:ed:d7:c8:95",
"KeyName": "red-medicine"
}
]
}
If no explicit Account ID is set, LocalStack falls back to default. In this example, no resources are returned.
$ awslocal ec2 describe-key-pairs
{
"KeyPairs": []
}