I am deploying some services on a different cloud than the AWS cloud, but that exposes AWS compatible endpoints.
I was given an endpoints.json file that looks like this
{
"partitions": [
{
"defaults": {
"hostname": "{service}.{region}.{dnsSuffix}",
"protocols": [
"https"
],
"signatureVersions": [
"v4"
]
},
"dnsSuffix": "outscale.com",
"partition": "osc",
"partitionName": "Outscale",
"regionRegex": "^(cloudgouv|us|eu|ap)\\-\\w+\\-\\d+$",
"regions": {
"eu-west-2": {
"description": "EU (Paris)"
},
[...]
},
"services": {
"ec2": {
"endpoints": {
"eu-west-2": {"hostname": "fcu.eu-west-2.outscale.com"},
[...]
}
},
How can I easily import this in my AWS sdk v3 ? When looking at the doc there seems to be something quite similar available, but I'm not sure I understand how to load this config from my ruby code
I know I can do something like this
Aws.config.update(
region: 'cloudgouv-eu-west-1'
)
But I'm not sure how to import the whole config (and especially the endpoints name, etc.) so they will automatically be used by underlying sdks without changing too much code
I ended up using AWS internal API to add partitions
# config/initializers/aws.rb
# Monkeypatch the list of AWS endpoints
new_partitions = JSON.parse(
File.read(
Rails.root.join('config', 'aws_endpoints_outscale.json')
)
)
Aws::Partitions.add(new_partitions)
Aws.config.update(
region: ENV['AWS_REGION'],
endpoint: 'outscale.com',
)