Lightsail / Client / create_subdomain

create_subdomain

Lightsail.Client.create_subdomain(**kwargs)

Creates a Lightsail subdomain, such as mysite, with the web address mysite.amazonlightsail.com. After the subdomain is created, use the UpdateSubdomainAssociation action to associate it with a Lightsail resource.

When you create a nested subdomain, such as blog.mysite, and you don’t already have the top-level subdomain ( mysite), Lightsail adds the top-level subdomain to your account in the IMPLICIT state.

You can have up to 30 subdomains in your account. Nested subdomains, subdomains in the CREATE_FAILED state, and deleted subdomains that other accounts can’t create yet count toward this quota. Subdomains in the IMPLICIT state don’t count toward this quota.

See also: AWS API Documentation

Request Syntax

response = client.create_subdomain(
    subdomainName='string',
    tags=[
        {
            'key': 'string',
            'value': 'string'
        },
    ]
)
Parameters:
  • subdomainName (string) –

    [REQUIRED]

    The subdomain to create (for example, mysite or blog.mysite).

    A subdomain can contain one or two labels separated by a period ( .). Each label must start and end with a lowercase letter or a number, and can contain only lowercase letters, numbers, and hyphens ( -). The name can be up to 39 characters long, including periods. Labels that start with xn-- aren’t supported, and some names are reserved.

    Specify only the subdomain. A web address, such as mysite.amazonlightsail.com, isn’t accepted.

    To create a nested subdomain, you must own the top-level subdomain or be able to create it.

  • tags (list) –

    The tag keys and optional values to add to the subdomain during create.

    Use the TagResource action to tag a resource after it’s created.

    • (dict) –

      Describes a tag key and optional value assigned to an Amazon Lightsail resource.

      For more information about tags in Lightsail, see the Amazon Lightsail Developer Guide.

      • key (string) –

        The key of the tag.

        Constraints: Tag keys accept a maximum of 128 letters, numbers, spaces in UTF-8, or the following characters: + - = . _ : / @

      • value (string) –

        The value of the tag.

        Constraints: Tag values accept a maximum of 256 letters, numbers, spaces in UTF-8, or the following characters: + - = . _ : / @

Return type:

dict

Returns:

Response Syntax

{
    'subdomain': {
        'subdomainName': 'string',
        'arn': 'string',
        'fqdn': 'string',
        'depth': 123,
        'state': 'CREATING'|'CREATE_FAILED'|'UNATTACHED'|'ATTACHING'|'ATTACHED'|'DETACHING'|'TRANSFERRING'|'IMPLICIT',
        'attachedResource': {
            'arn': 'string',
            'name': 'string',
            'attachedAt': datetime(2015, 1, 1)
        },
        'attachingResource': {
            'arn': 'string',
            'name': 'string',
            'attachedAt': datetime(2015, 1, 1)
        },
        'location': {
            'availabilityZone': 'string',
            'regionName': 'us-east-1'|'us-east-2'|'us-west-1'|'us-west-2'|'eu-west-1'|'eu-west-2'|'eu-west-3'|'eu-central-1'|'eu-north-1'|'eu-south-2'|'ca-central-1'|'ap-east-1'|'ap-south-1'|'ap-southeast-1'|'ap-southeast-2'|'ap-northeast-1'|'ap-northeast-2'|'ap-southeast-3'|'ap-southeast-5'|'sa-east-1'
        },
        'createdAt': datetime(2015, 1, 1),
        'parentFqdn': 'string',
        'children': [
            {'... recursive ...'},
        ],
        'tags': [
            {
                'key': 'string',
                'value': 'string'
            },
        ]
    },
    'operation': {
        'id': 'string',
        'resourceName': 'string',
        'resourceType': 'ContainerService'|'Instance'|'StaticIp'|'KeyPair'|'InstanceSnapshot'|'Domain'|'PeeredVpc'|'LoadBalancer'|'LoadBalancerTlsCertificate'|'Disk'|'DiskSnapshot'|'RelationalDatabase'|'RelationalDatabaseSnapshot'|'ExportSnapshotRecord'|'CloudFormationStackRecord'|'Alarm'|'ContactMethod'|'Distribution'|'Certificate'|'Bucket'|'Subdomain',
        'createdAt': datetime(2015, 1, 1),
        'location': {
            'availabilityZone': 'string',
            'regionName': 'us-east-1'|'us-east-2'|'us-west-1'|'us-west-2'|'eu-west-1'|'eu-west-2'|'eu-west-3'|'eu-central-1'|'eu-north-1'|'eu-south-2'|'ca-central-1'|'ap-east-1'|'ap-south-1'|'ap-southeast-1'|'ap-southeast-2'|'ap-northeast-1'|'ap-northeast-2'|'ap-southeast-3'|'ap-southeast-5'|'sa-east-1'
        },
        'isTerminal': True|False,
        'operationDetails': 'string',
        'operationType': 'DeleteKnownHostKeys'|'DeleteInstance'|'CreateInstance'|'StopInstance'|'StartInstance'|'RebootInstance'|'OpenInstancePublicPorts'|'PutInstancePublicPorts'|'CloseInstancePublicPorts'|'AllocateStaticIp'|'ReleaseStaticIp'|'AttachStaticIp'|'DetachStaticIp'|'UpdateDomainEntry'|'DeleteDomainEntry'|'CreateDomain'|'DeleteDomain'|'CreateInstanceSnapshot'|'DeleteInstanceSnapshot'|'CreateInstancesFromSnapshot'|'CreateLoadBalancer'|'DeleteLoadBalancer'|'AttachInstancesToLoadBalancer'|'DetachInstancesFromLoadBalancer'|'UpdateLoadBalancerAttribute'|'CreateLoadBalancerTlsCertificate'|'DeleteLoadBalancerTlsCertificate'|'AttachLoadBalancerTlsCertificate'|'CreateDisk'|'DeleteDisk'|'AttachDisk'|'DetachDisk'|'CreateDiskSnapshot'|'DeleteDiskSnapshot'|'CreateDiskFromSnapshot'|'CreateRelationalDatabase'|'UpdateRelationalDatabase'|'DeleteRelationalDatabase'|'CreateRelationalDatabaseFromSnapshot'|'CreateRelationalDatabaseSnapshot'|'DeleteRelationalDatabaseSnapshot'|'UpdateRelationalDatabaseParameters'|'StartRelationalDatabase'|'RebootRelationalDatabase'|'StopRelationalDatabase'|'EnableAddOn'|'DisableAddOn'|'PutAlarm'|'GetAlarms'|'DeleteAlarm'|'TestAlarm'|'CreateContactMethod'|'GetContactMethods'|'SendContactMethodVerification'|'DeleteContactMethod'|'CreateDistribution'|'UpdateDistribution'|'DeleteDistribution'|'ResetDistributionCache'|'AttachCertificateToDistribution'|'DetachCertificateFromDistribution'|'UpdateDistributionBundle'|'SetIpAddressType'|'CreateCertificate'|'DeleteCertificate'|'CreateContainerService'|'UpdateContainerService'|'DeleteContainerService'|'CreateContainerServiceDeployment'|'CreateContainerServiceRegistryLogin'|'RegisterContainerImage'|'DeleteContainerImage'|'CreateBucket'|'DeleteBucket'|'CreateBucketAccessKey'|'DeleteBucketAccessKey'|'UpdateBucketBundle'|'UpdateBucket'|'SetResourceAccessForBucket'|'UpdateInstanceMetadataOptions'|'StartGUISession'|'StopGUISession'|'SetupInstanceHttps'|'GetProfile'|'CreateSubdomain'|'UpdateSubdomainAssociation'|'DeleteSubdomain',
        'status': 'NotStarted'|'Started'|'Failed'|'Completed'|'Succeeded',
        'statusChangedAt': datetime(2015, 1, 1),
        'errorCode': 'string',
        'errorDetails': 'string'
    }
}

Response Structure

  • (dict) –

    • subdomain (dict) –

      An object that describes the subdomain that was created.

      • subdomainName (string) –

        The subdomain (for example, mysite or blog.mysite). To get the web address, use the fqdn parameter.

      • arn (string) –

        The Amazon Resource Name (ARN) of the subdomain.

        If you create a subdomain with a depth of 2, such as blog.mysite, without first creating the subdomain with a depth of 1 ( mysite), Lightsail holds mysite for your account in the IMPLICIT state. It doesn’t have an ARN until you create a subdomain with that name.

      • fqdn (string) –

        The web address of the subdomain, which is the subdomain followed by amazonlightsail.com (for example, blog.mysite.amazonlightsail.com).

      • depth (integer) –

        The number of labels in the subdomain. A top-level subdomain, such as mysite, has a depth of 1. A nested subdomain, such as blog.mysite, has a depth of 2.

      • state (string) –

        The state of the subdomain.

        The following states are possible:

        • CREATING – The subdomain is being created.

        • CREATE_FAILED – The subdomain couldn’t be created. Delete the subdomain, and then create it again if the name is still available.

        • UNATTACHED – The subdomain is ready, and isn’t associated with a resource.

        • ATTACHING – The subdomain is being associated with a resource.

        • ATTACHED – The subdomain is associated with a resource, and routes traffic to it.

        • DETACHING – The subdomain is being disassociated from a resource.

        • TRANSFERRING – The subdomain is being moved from one resource to another resource.

        • IMPLICIT – The subdomain is the parent of one or more nested subdomains that you created, but you didn’t create the parent subdomain itself. You can’t associate or delete a subdomain in this state. To use it, create it with the CreateSubdomain action.

      • attachedResource (dict) –

        An object that describes the resource that the subdomain is associated with.

        When the subdomain is in the TRANSFERRING state, this is the resource that the subdomain is being moved from.

        • arn (string) –

          The Amazon Resource Name (ARN) of the resource.

        • name (string) –

          The name of the resource.

        • attachedAt (datetime) –

          The timestamp when the subdomain was associated with the resource.

      • attachingResource (dict) –

        An object that describes the resource that the subdomain is being associated with.

        This parameter is returned only when the subdomain is in the ATTACHING or TRANSFERRING state.

        • arn (string) –

          The Amazon Resource Name (ARN) of the resource.

        • name (string) –

          The name of the resource.

        • attachedAt (datetime) –

          The timestamp when the subdomain was associated with the resource.

      • location (dict) –

        An object that describes the location of the subdomain, such as the AWS Region.

        • availabilityZone (string) –

          The Availability Zone. Follows the format us-east-2a (case-sensitive).

        • regionName (string) –

          The Amazon Web Services Region name.

      • createdAt (datetime) –

        The timestamp when the subdomain was created.

      • parentFqdn (string) –

        The web address of the parent subdomain (for example, mysite.amazonlightsail.com for blog.mysite).

        This parameter isn’t returned for a subdomain with a depth of 1.

      • children (list) –

        An array of objects that describe the nested subdomains of the subdomain.

        This parameter is returned only by the GetSubdomains action when you don’t specify a subdomain.

        • (dict) –

          Describes a Lightsail subdomain. A subdomain is the name that you choose, such as mysite or blog.mysite. Its web address is the subdomain followed by amazonlightsail.com, such as blog.mysite.amazonlightsail.com. You can associate a subdomain with a Lightsail resource to make the resource reachable at the web address.

      • tags (list) –

        The tag keys and optional values for the subdomain. For more information about tags in Lightsail, see the Lightsail Developer Guide.

        This parameter is returned only by the GetSubdomains action when you specify a subdomain.

        • (dict) –

          Describes a tag key and optional value assigned to an Amazon Lightsail resource.

          For more information about tags in Lightsail, see the Amazon Lightsail Developer Guide.

          • key (string) –

            The key of the tag.

            Constraints: Tag keys accept a maximum of 128 letters, numbers, spaces in UTF-8, or the following characters: + - = . _ : / @

          • value (string) –

            The value of the tag.

            Constraints: Tag values accept a maximum of 256 letters, numbers, spaces in UTF-8, or the following characters: + - = . _ : / @

    • operation (dict) –

      An object that describes the result of the action, such as the status of the request, the timestamp of the request, and the resources affected by the request.

      • id (string) –

        The ID of the operation.

      • resourceName (string) –

        The resource name.

      • resourceType (string) –

        The resource type.

      • createdAt (datetime) –

        The timestamp when the operation was initialized ( 1479816991.349).

      • location (dict) –

        The Amazon Web Services Region and Availability Zone.

        • availabilityZone (string) –

          The Availability Zone. Follows the format us-east-2a (case-sensitive).

        • regionName (string) –

          The Amazon Web Services Region name.

      • isTerminal (boolean) –

        A Boolean value indicating whether the operation is terminal.

      • operationDetails (string) –

        Details about the operation ( Debian-1GB-Ohio-1).

      • operationType (string) –

        The type of operation.

      • status (string) –

        The status of the operation.

      • statusChangedAt (datetime) –

        The timestamp when the status was changed ( 1479816991.349).

      • errorCode (string) –

        The error code.

      • errorDetails (string) –

        The error details.

Exceptions