1. Custom Domain Names for AI Services


    To set up a custom domain name for AI services, you will need to create and configure a domain name and map it to your service's endpoint. The specifics can vary depending on the cloud provider you're using, but generally, this involves creating a DNS record and an API Gateway configuration or an equivalent service in Azure or GCP.

    In this example, I'll show you how to set up a custom domain for an AWS API Gateway using Pulumi with Python. This will involve creating a DomainName and an ApiMapping resource, which maps a custom domain name to a specific stage of an API deployment.

    Here's what you need for this setup:

    • An SSL/TLS certificate for your custom domain in AWS Certificate Manager.
    • An API Gateway API that you want to attach the custom domain name to.
    • The domain name you want to map to your API.

    In the following Pulumi program:

    • We create a new domain name for our API Gateway.
    • We set up a DNS record to point to our API's domain name.
    • We create an API mapping to connect the deployed stage of our API with the custom domain.
    import pulumi import pulumi_aws as aws # Replace the following with your actual values custom_domain_name = "api.example.com" certificate_arn = "arn:aws:acm:<region>:<account-id>:certificate/<certificate-id>" api_gateway_id = "abcdefghij" # The identifier of your API Gateway api_gateway_stage_name = "v1" # Create the custom domain for the API Gateway. domain_name = aws.apigatewayv2.DomainName("custom-domain-name", domain_name=custom_domain_name, domain_name_configuration=aws.apigatewayv2.DomainNameDomainNameConfigurationArgs( certificate_arn=certificate_arn, endpoint_type="REGIONAL", security_policy="TLS_1_2", ) ) # Create the DNS record for the custom domain. dns_record = aws.route53.Record("dns-record", name=custom_domain_name, type="A", zone_id="Z2FDTNDATAQYW2", # The hosted zone ID of your registered domain aliases=[ aws.route53.RecordAliasArgs( name=domain_name.domain_name_configuration.apply(lambda conf: conf.target_domain_name), zone_id=domain_name.domain_name_configuration.apply(lambda conf: conf.hosted_zone_id), evaluate_target_health=True, ) ] ) # Create an API mapping from the custom domain to a specific stage of the API Gateway. api_mapping = aws.apigatewayv2.ApiMapping("api-mapping", api_id=api_gateway_id, domain_name=domain_name.domain_name, stage=api_gateway_stage_name, ) # Output the API's custom domain URL. pulumi.export('api_custom_domain_url', pulumi.Output.concat("https://", custom_domain_name))

    In this program:

    • We define the custom domain name we want to use for our API.
    • We specify the ARN of the SSL certificate we've registered via AWS Certificate Manager.
    • A DomainName resource is created using the aws.apigatewayv2.DomainName class, which requires the custom domain name and domain name configuration.
    • A DNS 'A' record is managed with aws.route53.Record. The RecordAliasArgs are dynamically set using the .apply() method, which allows us to transform and access properties of the domain name configuration.
    • The ApiMapping resource is created to link the custom domain name to a specific deployment stage of the deployed API Gateway.
    • Finally, we use pulumi.export to output our API's custom domain URL.

    Please note that to successfully execute this Pulumi program, you need to have your AWS credentials configured, and the AWS Pulumi provider should be set up. Additionally, you must have your API Gateway and the SSL/TLS certificate pre-created in your AWS environment.

    For more detailed information on the resources used:

    This is just one example for AWS. Similar concepts and resources apply for managing custom domain names in other cloud providers like Azure and GCP, with their respective Pulumi resources and providers.