以下是一个Python示例,演示如何设置正确的DNS记录:
import boto3
client = boto3.client('route53')
response = client.change_resource_record_sets(
HostedZoneId='HOSTED_ZONE_ID',
ChangeBatch={
'Changes': [
{
'Action': 'CREATE',
'ResourceRecordSet': {
'Name': 'example.com',
'Type': 'A',
'TTL': 300,
'ResourceRecords': [
{
'Value': 'ELASTIC_BEANSTALK_IP_ADDRESS'
}
]
}
}
]
}
)
print(response)
请确保将HOSTED_ZONE_ID
替换为AWS Route 53中托管区域的ID,并将ELASTIC_BEANSTALK_IP_ADDRESS
替换为Elastic Beanstalk环境中的IP地址。此代码将创建一个名为'example.com”的A记录,并将其路由到Elastic Beanstalk环境。