Module: Aws::Partitions
- Extended by:
- Enumerable
- Defined in:
- lib/aws-partitions.rb,
lib/aws-partitions/region.rb,
lib/aws-partitions/service.rb,
lib/aws-partitions/partition.rb,
lib/aws-partitions/partition_list.rb,
lib/aws-partitions/endpoint_provider.rb
Overview
A Partition is a group of AWS Region and Service objects. You can use a partition to determine what services are available in a region, or what regions a service is available in.
## Partitions
**AWS accounts are scoped to a single partition**. You can get a partition by name. Valid partition names include:
-
‘“aws”` - Public AWS partition
-
‘“aws-cn”` - AWS China
-
‘“aws-us-gov”` - AWS GovCloud
To get a partition by name:
aws = Aws::Partitions.partition('aws')
You can also enumerate all partitions:
Aws::Partitions.each do |partition|
puts partition.name
end
## Regions
A Partition is divided up into one or more regions. For example, the “aws” partition contains, “us-east-1”, “us-west-1”, etc. You can get a region by name. Calling Partition#region will return an instance of Region.
region = Aws::Partitions.partition('aws').region('us-west-2')
region.name
#=> "us-west-2"
You can also enumerate all regions within a partition:
Aws::Partitions.partition('aws').regions.each do |region|
puts region.name
end
Each Region object has a name, description and a list of services available to that region:
us_west_2 = Aws::Partitions.partition('aws').region('us-west-2')
us_west_2.name #=> "us-west-2"
us_west_2.description #=> "US West (Oregon)"
us_west_2.partition_name "aws"
us_west_2.services #=> #<Set: {"APIGateway", "AutoScaling", ... }
To know if a service is available within a region, you can call ‘#include?` on the set of service names:
region.services.include?('DynamoDB') #=> true/false
The service name should be the service’s module name as used by the AWS SDK for Ruby. To find the complete list of supported service names, see Partition#services.
Its also possible to enumerate every service for every region in every partition.
Aws::Partitions.partitions.each do |partition|
partition.regions.each do |region|
region.services.each do |service_name|
puts "#{partition.name} -> #{region.name} -> #{service_name}"
end
end
end
## Services
A Partition has a list of services available. You can get a single Service by name:
Aws::Partitions.partition('aws').service('DynamoDB')
You can also enumerate all services in a partition:
Aws::Partitions.partition('aws').services.each do |service|
puts service.name
end
Each Service object has a name, and information about regions that service is available in.
service.name #=> "DynamoDB"
service.partition_name #=> "aws"
service.regions #=> #<Set: {"us-east-1", "us-west-1", ... }
Some services have multiple regions, and others have a single partition wide region. For example, IAM has a single region in the “aws” partition. The Service#regionalized? method indicates when this is the case.
iam = Aws::Partitions.partition('aws').service('IAM')
iam.regionalized? #=> false
service.partition_region #=> "aws-global"
Its also possible to enumerate every region for every service in every partition.
Aws::Partitions.partitions.each do |partition|
partition.services.each do |service|
service.regions.each do |region_name|
puts "#{partition.name} -> #{region_name} -> #{service.name}"
end
end
end
## Service Names
Service names are those used by the the AWS SDK for Ruby. They correspond to the service’s module.
Defined Under Namespace
Classes: EndpointProvider, Partition, PartitionList, Region, Service
Class Method Summary collapse
- .add(new_partitions) ⇒ Object
- .clear ⇒ Object
- .default_partition_list ⇒ PartitionList private
- .defaults ⇒ Hash private
- .each(&block) ⇒ Enumerable<Partition>
-
.partition(name) ⇒ Partition
Return the partition with the given name.
-
.partitions ⇒ Enumerable<Partition>
Returns an array with every partitions.
-
.service_ids ⇒ Hash<String,String>
Returns a map of service module names to their id as used in the endpoints.json document.
Class Method Details
.add(new_partitions) ⇒ Object
189 190 191 192 193 194 |
# File 'lib/aws-partitions.rb', line 189 def add(new_partitions) new_partitions['partitions'].each do |partition| default_partition_list.add_partition(Partition.build(partition)) defaults['partitions'] << partition end end |
.clear ⇒ Object
197 198 199 200 |
# File 'lib/aws-partitions.rb', line 197 def clear default_partition_list.clear defaults['partitions'].clear end |
.default_partition_list ⇒ PartitionList
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
204 205 206 |
# File 'lib/aws-partitions.rb', line 204 def default_partition_list @default_partition_list ||= PartitionList.build(defaults) end |
.defaults ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
210 211 212 213 214 215 |
# File 'lib/aws-partitions.rb', line 210 def defaults @defaults ||= begin path = File.('../../partitions.json', __FILE__) JSON.load(File.read(path)) end end |
.each(&block) ⇒ Enumerable<Partition>
134 135 136 |
# File 'lib/aws-partitions.rb', line 134 def each(&block) default_partition_list.each(&block) end |
.partition(name) ⇒ Partition
Return the partition with the given name. A partition describes the services and regions available in that partition.
aws = Aws::Partitions.partition('aws')
puts "Regions available in the aws partition:\n"
aws.regions.each do |region|
puts region.name
end
puts "Services available in the aws partition:\n"
aws.services.each do |services|
puts services.name
end
161 162 163 |
# File 'lib/aws-partitions.rb', line 161 def partition(name) default_partition_list.partition(name) end |
.partitions ⇒ Enumerable<Partition>
Returns an array with every partitions. A partition describes the services and regions available in that partition.
Aws::Partitions.partitions.each do |partition|
puts "Regions available in #{partition.name}:\n"
partition.regions.each do |region|
puts region.name
end
puts "Services available in #{partition.name}:\n"
partition.services.each do |service|
puts service.name
end
end
183 184 185 |
# File 'lib/aws-partitions.rb', line 183 def partitions default_partition_list end |
.service_ids ⇒ Hash<String,String>
Returns a map of service module names to their id as used in the endpoints.json document.
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/aws-partitions.rb', line 220 def service_ids @service_ids ||= begin # service ids { 'ACM' => 'acm', 'APIGateway' => 'apigateway', 'AppStream' => 'appstream2', 'ApplicationAutoScaling' => 'application-autoscaling', 'ApplicationDiscoveryService' => 'discovery', 'Athena' => 'athena', 'AutoScaling' => 'autoscaling', 'Batch' => 'batch', 'Budgets' => 'budgets', 'CloudDirectory' => 'clouddirectory', 'CloudFormation' => 'cloudformation', 'CloudFront' => 'cloudfront', 'CloudHSM' => 'cloudhsm', 'CloudHSMV2' => 'cloudhsmv2', 'CloudSearch' => 'cloudsearch', 'CloudTrail' => 'cloudtrail', 'CloudWatch' => 'monitoring', 'CloudWatchEvents' => 'events', 'CloudWatchLogs' => 'logs', 'CodeBuild' => 'codebuild', 'CodeCommit' => 'codecommit', 'CodeDeploy' => 'codedeploy', 'CodePipeline' => 'codepipeline', 'CodeStar' => 'codestar', 'CognitoIdentity' => 'cognito-identity', 'CognitoIdentityProvider' => 'cognito-idp', 'CognitoSync' => 'cognito-sync', 'ConfigService' => 'config', 'CostandUsageReportService' => 'cur', 'DAX' => 'dax', 'DataPipeline' => 'datapipeline', 'DatabaseMigrationService' => 'dms', 'DeviceFarm' => 'devicefarm', 'DirectConnect' => 'directconnect', 'DirectoryService' => 'ds', 'DynamoDB' => 'dynamodb', 'DynamoDBStreams' => 'streams.dynamodb', 'EC2' => 'ec2', 'ECR' => 'ecr', 'ECS' => 'ecs', 'EFS' => 'elasticfilesystem', 'EMR' => 'elasticmapreduce', 'ElastiCache' => 'elasticache', 'ElasticBeanstalk' => 'elasticbeanstalk', 'ElasticLoadBalancing' => 'elasticloadbalancing', 'ElasticLoadBalancingV2' => 'elasticloadbalancing', 'ElasticTranscoder' => 'elastictranscoder', 'ElasticsearchService' => 'es', 'Firehose' => 'firehose', 'GameLift' => 'gamelift', 'Glacier' => 'glacier', 'Glue' => 'glue', 'Greengrass' => 'greengrass', 'Health' => 'health', 'IAM' => 'iam', 'ImportExport' => 'importexport', 'Inspector' => 'inspector', 'IoT' => 'iot', 'KMS' => 'kms', 'Kinesis' => 'kinesis', 'KinesisAnalytics' => 'kinesisanalytics', 'Lambda' => 'lambda', 'LambdaPreview' => 'lambda', 'Lex' => 'runtime.lex', 'LexModelBuildingService' => 'models.lex', 'Lightsail' => 'lightsail', 'MTurk' => 'mturk-requester', 'MachineLearning' => 'machinelearning', 'MarketplaceCommerceAnalytics' => 'marketplacecommerceanalytics', 'MarketplaceEntitlementService' => 'entitlement.marketplace', 'MarketplaceMetering' => 'metering.marketplace', 'MigrationHub' => 'mgh', 'OpsWorks' => 'opsworks', 'OpsWorksCM' => 'opsworks-cm', 'Organizations' => 'organizations', 'Pinpoint' => 'pinpoint', 'Polly' => 'polly', 'RDS' => 'rds', 'Redshift' => 'redshift', 'Rekognition' => 'rekognition', 'ResourceGroupsTaggingAPI' => 'tagging', 'Route53' => 'route53', 'Route53Domains' => 'route53domains', 'S3' => 's3', 'SES' => 'email', 'SMS' => 'sms', 'SNS' => 'sns', 'SQS' => 'sqs', 'SSM' => 'ssm', 'STS' => 'sts', 'SWF' => 'swf', 'ServiceCatalog' => 'servicecatalog', 'Shield' => 'shield', 'SimpleDB' => 'sdb', 'Snowball' => 'snowball', 'States' => 'states', 'StorageGateway' => 'storagegateway', 'Support' => 'support', 'WAF' => 'waf', 'WAFRegional' => 'waf-regional', 'WorkDocs' => 'workdocs', 'WorkSpaces' => 'workspaces', 'XRay' => 'xray', } # end service ids end end |