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:

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: CloudProvider

Amazon Web Services.

Parameters:

allow_in_tests (bool) – Allow it to reach AWS in the unit tests, e.g. in a test tagged INFRASTRUCTURE.

__init__(allow_in_tests=False, **kwargs)[source]
property account_id: str | None

The cloud account’s id, or None if the provider is not authenticated.

property base: AWSBase

The low-level AWS helper that authenticates, created when it is first used.

property certificates: ACMCertificateService

The provider’s TLS certificate service.

property dns: Route53DNSService

The provider’s DNS service.

property eks: AWSEks

The low-level EKS helper.

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:

dict[str, Any]

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.

property ready: bool

Whether the service is authenticated and connected, i.e. it can be used.

require_live()[source]

Refuse to reach AWS from the unit tests, unless allowed.

Raises:

InfrastructureConfigurationError – In the unit tests, unless allowed.

Return type:

None

property sdk_version: str

The version of the provider’s SDK.

property session: Session | None

The boto3 session, for AWS-specific backends that need clients of their own.

e.g. EKSNodeGroupBackend.

update_kubeconfig()[source]

Write the kubeconfig of the platform’s Kubernetes cluster, for kubectl.

Return type:

bool

Returns:

True if it was written.

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: DNSService

AWS Route53, as the platform’s DNS.

Parameters:

provider (AWSProvider) – The AWS provider, which authenticates with AWS.

__init__(provider, **kwargs)[source]
property ready: bool

Whether the service is authenticated and connected, i.e. it can be used.

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:

DNSRecord

smarter.apps.infrastructure.providers.aws.dns.to_record_set(record)[source]

A DNSRecord as a Route53 record set.

TXT values are quoted, as Route53 requires.

Return type:

dict[str, Any]

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:

DNSZone

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: CertificateService

AWS 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.

__init__(provider, dns, **kwargs)[source]
property acm: AWSCertificateManager

The low-level ACM helper, created when it is first used.

property ready: bool

Whether the service is authenticated and connected, i.e. it can be used.

smarter.apps.infrastructure.providers.aws.certificates.to_certificate(description)[source]

An ACM certificate’s description as a Certificate.

Return type:

Certificate