We have an application we deploy with terraform across many AWS regions. Some resource/features are not available across all regions (main problem we encounter is in govcloud regions, where a lot of resources are not supported yet).
We develop on a standard region (us-west-2), so we discover these incompatibility errors only on the multi-regions deployment.
Is anyone familiar with a tool to validate a resource/feature is compatible in all regions ? preferably for terraform, but any automated tool will be appreciated
The use case:
I have a aws_s3_bucket
terraform resource, and added a new attribute acceleration_status
for example:
resource "aws_s3_bucket" "my_bucket" {
bucket = "my-bucket"
acceleration_status = "Enabled"
versioning {
enabled = true
}
.
.
.
}
This will work on all regions deployment but will fail in govcloud
.
Optimally I am searching for an automated validation for this level of resource attributes per region. without explicitly stating resources/attributes, but by auto extract it from TF code
CodePudding user response:
You can use aws ssm get-parameters-by-path
to list all available services in a given region.
For example:
(this is sorted and giving only the first 10 results, for brevity)
$ aws ssm get-parameters-by-path \
--path /aws/service/global-infrastructure/regions/us-east-2/services --output json | \
jq '.Parameters[].Name' | sort | head -10
Or use boto3
:
resources = boto3.Session().get_available_regions('cloudsearch')
to get a list of all the regions where cloudsearch service is available.
Both approaches can be fully automated.
CodePudding user response:
@yuval yacoby Hi, I guess you can take use of python library called 'aws-service-availability'. Just install this library using pip3 command
pip3 install -U aws-service-availability
then run below command with region as input
aws-service-availability list-supported-services <region>
Eg : aws-service-availability list-supported-services eu-north-1
Even you can list un-supported services too
aws-service-availability list-unsupported-services eu-north-1
Probably, you can write small shell/python script, where you keep all regions as list and you can loop over this list and execute aws-service-availability command for each region and get details
Reference : https://github.com/jensroland/aws-service-availability