AWS Provider
The AWS cloud provider.
AWSProvider replaces smarter.common.helpers.aws_helpers.AWSInfrastructureConfig. It
authenticates with AWS, with smarter_settings’ AWS credentials, and implements:
DNS, with Route53:
Route53DNSService.TLS certificates, with ACM:
ACMCertificateService.the Kubernetes cluster’s kubeconfig and description, with EKS.
Of the AWS services that the old helpers wrapped, only these are used by the platform. API Gateway, DynamoDB, IAM, Lambda, RDS, Rekognition and S3 were not, and were removed.
In the unit tests, it refuses to reach AWS, unless allow_in_tests is True, because the
Smarter containers’ AWS credentials are real.
- class smarter.apps.infrastructure.providers.aws.provider.AWSProvider(allow_in_tests=False, **kwargs)[source]
Bases:
CloudProviderAmazon Web Services.
- Parameters:
allow_in_tests (
bool) – Allow it to reach AWS in the unit tests, e.g. in a test taggedINFRASTRUCTURE.
- property account_id: str | None
The cloud account’s id, or None if the provider is not authenticated.
- property certificates: ACMCertificateService
The provider’s TLS certificate service.
- property dns: Route53DNSService
The provider’s DNS service.
- get_kubernetes_cluster_info()[source]
Describe the platform’s Kubernetes cluster, e.g. for the status API.
- Raises:
InfrastructureNotReadyError – If the provider is not ready.
- Return type:
- property identity: dict[str, Any] | None
The identity that the provider authenticates as, e.g. its account, or None.
- name: str = 'aws'
The provider’s name, see
CloudProviders.
- require_live()[source]
Refuse to reach AWS from the unit tests, unless allowed.
- Raises:
InfrastructureConfigurationError – In the unit tests, unless allowed.
- Return type:
The DNS service of AWS: Route53.
Route53DNSService implements the primitives of
DNSService with the low-level
AWSRoute53 helper, and
translates between Route53’s hosted zones and record sets and the provider-independent
DNSZone and
DNSRecord.
- class smarter.apps.infrastructure.providers.aws.dns.Route53DNSService(provider, **kwargs)[source]
Bases:
DNSServiceAWS Route53, as the platform’s DNS.
- Parameters:
provider (
AWSProvider) – The AWS provider, which authenticates with AWS.
- property route53: AWSRoute53
The low-level Route53 helper, created when it is first used.
- smarter.apps.infrastructure.providers.aws.dns.to_record(record_set)[source]
A Route53 record set as a
DNSRecord.TXT values are unquoted.
- Return type:
- smarter.apps.infrastructure.providers.aws.dns.to_record_set(record)[source]
A
DNSRecordas a Route53 record set.TXT values are quoted, as Route53 requires.
- smarter.apps.infrastructure.providers.aws.dns.to_zone(hosted_zone, delegation_set=None)[source]
A Route53 hosted zone, and optionally its delegation set, as a
DNSZone.- Return type:
The certificate service of AWS: AWS Certificate Manager (ACM).
ACMCertificateService implements the primitives of
CertificateService with the
low-level AWSCertificateManager
helper. A certificate’s id is its ARN.
- class smarter.apps.infrastructure.providers.aws.certificates.ACMCertificateService(provider, dns, **kwargs)[source]
Bases:
CertificateServiceAWS Certificate Manager, as the platform’s certificate authority.
- Parameters:
provider (
AWSProvider) – The AWS provider, which authenticates with AWS.dns (
DNSService) – The DNS service of the validation records.
- property acm: AWSCertificateManager
The low-level ACM helper, created when it is first used.