It is actually very tricky the way how it works.
You can access a secret from "Account A and eu-central-1 region" that is created in "Account B and eu-west-1 region" using AWS CLI by specifying --region
parameter to match with the region of the source Account B (eu-west-1):
# Account A
# region: eu-central-1
$ aws secretsmanager get-secret-value --secret-id="arn:aws:secretsmanager:eu-west-1:1234567:secret:my-secret-smart9x" --region eu-west-1
# {valid result}
If you do not specify the --region eu-west-1
, despite the fact that you indicate the ARN of the secret, which includes the region where the secret is located, the call to AWS Secrets Manager API is made to the region of the client (eu-central-1), resulting in the following error:
$ aws secretsmanager get-secret-value --secret-id="arn:aws:secretsmanager:eu-west-1:1234567:secret:my-secret-smart9x"
An error occurred (AccessDeniedException) when calling the GetSecretValue operation: User: arn:aws:sts::7654321:assumed-role/my-role/my-session is not authorized to perform: secretsmanager:GetSecretValue on resource: arn:aws:secretsmanager:eu-west-1:1234567:secret:my-secret-smart9x because no resource-based policy allows the secretsmanager:GetSecretValue action
This can be solved without Secret Replication to another region (no additional costs) by always specifying the --region
parameter to the request when you use AWC CLI or SDK. The same applies to terraform, where you can probably use a different provider in some cases.
However, when it comes to Lambda Event Source or other AWS components (for example a resource needs to be created in region eu-west-1 and access a secret from region eu-central-1, https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping#amazon-mq-activemq) that make the call to AWS Secrets Manager by only specifying the ARN (user has no possibility to specify the region where is the secret), you MUST replicate the secret to the same region where the consumer is calling from, which means extra costs (basically, $0.40 per secret, $0.40 per replica).
Can't AWS just detect that secret we try to get from Account A is in eu-west-1 region, based on the ARN? No? Yes?
ref: https://aws.amazon.com/blogs/security/how-to-replicate-secrets-aws-secrets-manager-multiple-regions/