The services package provides functions for working with AWS services and regions, including listing services, finding services in specific regions, and getting service operations.
import "github.com/myerscode/aws-meta/pkg/services"Returns detailed information about all AWS services including service IDs, full names, operations, and metadata.
func ServiceMeta() (aws.ServiceSchemas, error)Returns:
aws.ServiceSchemas: A map of service schemas containing detailed service information (keyed by service ID)error: An error if there's an issue reading the manifest
Example:
services, err := services.ServiceMeta()
if err != nil {
log.Fatal(err)
}
for serviceId, service := range services {
fmt.Printf("Service: %s\n", service.ServiceFullName)
fmt.Printf(" ID: %s\n", service.ServiceId)
fmt.Printf(" Operations: %d\n", len(service.Operations))
fmt.Printf(" Protocol: %s\n", service.Protocol)
}Service Schema Fields:
ServiceId: Service identifier (e.g., "S3", "EC2", "Lambda")ServiceFullName: Full service name (e.g., "Amazon Simple Storage Service")APIVersion: API version for the serviceEndpointPrefix: Endpoint prefix used in service URLsProtocol: Communication protocol (e.g., "rest-xml", "json")Operations: Array of available operations for the serviceGlobalEndpoint: Global endpoint URL (if applicable)SignatureVersion: AWS signature version usedJSONVersion: JSON version (for JSON-based services)TargetPrefix: Target prefix (for JSON-based services)
Returns detailed information about AWS services available in the specified region. This function combines the regional availability data with comprehensive service metadata.
func ServiceMetaForRegion(regionName string) (aws.ServiceSchemas, error)Parameters:
regionName: The AWS region name (e.g., "us-east-1", "eu-west-1")
Returns:
aws.ServiceSchemas: A map of service schemas containing detailed service information for services available in the regionerror: An error if the region name is invalid or if there's an issue reading the manifest
Example:
services, err := services.ServiceMetaForRegion("us-east-1")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Found %d services available in us-east-1\n", len(services))
for serviceId, service := range services {
fmt.Printf("Service: %s\n", service.ServiceFullName)
fmt.Printf(" ID: %s\n", service.ServiceId)
fmt.Printf(" Endpoint: %s\n", service.EndpointPrefix)
fmt.Printf(" Operations: %d\n", len(service.Operations))
}Notes:
- The returned services are filtered to only include those available in the specified region
- Some endpoint prefixes may map to multiple services (e.g., "rds" includes RDS, Neptune, and DocumentDB)
- The function returns the same service metadata structure as
ServiceMeta()but filtered by regional availability
Error Cases:
- Invalid region name:
invalid region name: invalid-region-123 - Empty region name:
invalid region name: - Case sensitivity: Region names must match exactly (e.g., "us-east-1", not "US-EAST-1")
Returns a list of all AWS region names across all partitions.
func AllRegionNames() []stringReturns:
[]string: A sorted list of all AWS region names (e.g., "us-east-1", "eu-west-1", "ap-southeast-1")
Example:
regions := services.AllRegionNames()
fmt.Printf("Total regions: %d\n", len(regions))
for _, region := range regions[:5] { // Show first 5
fmt.Printf(" - %s\n", region)
}Region Types Include:
- Standard regions: us-east-1, us-west-2, eu-west-1, etc.
- China regions: cn-north-1, cn-northwest-1
- GovCloud regions: us-gov-east-1, us-gov-west-1
- Opt-in regions: Various newer regions that require explicit opt-in
Returns a list of all AWS service full names.
func AllServiceNames() []stringReturns:
[]string: A sorted list of AWS service full names (e.g., "AWS Certificate Manager", "Amazon Simple Storage Service")
Example:
serviceNames := services.AllServiceNames()
fmt.Printf("Total services: %d\n", len(serviceNames))
for _, service := range serviceNames[:3] { // Show first 3
fmt.Printf(" - %s\n", service)
}
// Output might include:
// - AWS Certificate Manager
// - Amazon Simple Storage Service
// - Amazon Elastic Compute CloudReturns a list of service names available in the specified region.
func ServicesInRegion(regionName string) ([]string, error)Parameters:
regionName: The AWS region name (e.g., "us-east-1", "eu-west-1")
Returns:
[]string: A sorted list of service names available in the regionerror: An error if the region name is invalid or if there's an issue reading the manifest
Example:
serviceList, err := services.ServicesInRegion("us-east-1")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Services in us-east-1: %d\n", len(serviceList))Error Cases:
- Invalid region name:
invalid region name: invalid-region-123 - Empty region name:
invalid region name: - Case sensitivity: Region names must match exactly (e.g., "us-east-1", not "US-EAST-1")
Returns a list of operation names available for the specified service ID.
func ServiceOperationsByServiceId(serviceId string) ([]string, error)Parameters:
serviceId: The AWS service ID (e.g., "ACM", "S3", "EC2")
Returns:
[]string: A sorted list of operation names available for the serviceerror: An error if the service ID is invalid or if there's an issue reading the manifest
Example:
operations, err := services.ServiceOperationsByServiceId("ACM")
if err != nil {
log.Fatal(err)
}
fmt.Printf("ACM operations: %d\n", len(operations))
// Might show: ACM operations: 16Common Service IDs:
ACM: AWS Certificate ManagerS3: Amazon Simple Storage ServiceEC2: Amazon Elastic Compute CloudLambda: AWS LambdaRDS: Amazon Relational Database Service
Error Cases:
- Invalid service ID:
invalid service ID: INVALID-SERVICE - Case sensitivity: Service IDs are case-sensitive and typically uppercase
Returns a list of operation names available for the specified service name.
func ServiceOperationsByServiceName(serviceName string) ([]string, error)Parameters:
serviceName: The AWS service full name (e.g., "AWS Certificate Manager", "Amazon Simple Storage Service")
Returns:
[]string: A sorted list of operation names available for the serviceerror: An error if the service name is invalid or if there's an issue reading the manifest
Example:
operations, err := services.ServiceOperationsByServiceName("AWS Certificate Manager")
if err != nil {
log.Fatal(err)
}
fmt.Printf("AWS Certificate Manager operations: %d\n", len(operations))Common Service Names:
AWS Certificate Manager: SSL/TLS certificate managementAmazon Simple Storage Service: Object storage serviceAmazon Elastic Compute Cloud: Virtual server hostingAWS Lambda: Serverless compute serviceAmazon Relational Database Service: Managed database service
Error Cases:
- Invalid service name:
invalid service name: Invalid Service Name - Case sensitivity: Service names must match exactly as they appear in AWS documentation
Alias for ServiceOperationsByServiceId for convenience.
func ServiceOperations(serviceId string) ([]string, error)This function provides the same functionality as ServiceOperationsByServiceId but with a shorter name for convenience.
Parameters:
serviceId: The AWS service ID (e.g., "ACM", "S3", "EC2")
Returns:
[]string: A sorted list of operation names available for the serviceerror: An error if the service ID is invalid or if there's an issue reading the manifest
Example:
operations, err := services.ServiceOperations("S3")
if err != nil {
log.Fatal(err)
}
fmt.Printf("S3 operations: %d\n", len(operations))
// Might show: S3 operations: 108Service and region data is sourced from the official AWS Botocore library:
- Regions: From
botocore/data/endpoints.json - Services: From
botocore/data/*/service-*.jsonfiles - Operations: Extracted from individual service definition files
Functions that return errors follow Go conventions:
- Success:
errorisnil - Failure:
errorcontains a descriptive message - Input validation: Invalid inputs return specific error messages
- Case sensitivity: All inputs are case-sensitive and must match AWS conventions
- All data is loaded from pre-generated manifest files
- Functions return quickly as data is already parsed and sorted
- No network calls are made during function execution
- Data is cached in memory after first access