65 lines
3.3 KiB
TypeScript
65 lines
3.3 KiB
TypeScript
import type {CloudProvider, FieldSchema, ServiceSchema, TableColumnSchema} from './types'
|
|
|
|
/** A domain name of dot-separated labels, with or without the trailing dot. */
|
|
export const DNS_ZONE_NAME_PATTERN = '^(?=.{1,253}\\.?$)([a-zA-Z0-9_](?:[a-zA-Z0-9_-]{0,61}[a-zA-Z0-9_])?\\.)*[a-zA-Z0-9_](?:[a-zA-Z0-9_-]{0,61}[a-zA-Z0-9_])?\\.?$'
|
|
|
|
/** The record types Route 53 accepts in ChangeResourceRecordSets. */
|
|
export const DNS_RECORD_TYPES = ['A', 'AAAA', 'CAA', 'CNAME', 'DS', 'HTTPS', 'MX', 'NAPTR', 'NS', 'PTR', 'SOA', 'SPF', 'SRV', 'SSHFP', 'SVCB', 'TLSA', 'TXT'] as const
|
|
|
|
const zoneColumns: TableColumnSchema[] = [
|
|
{name: 'name', label: 'Domain'},
|
|
{name: 'visibility', label: 'Type', path: 'metadata.visibility', format: 'badge'},
|
|
{name: 'recordCount', label: 'Records', path: 'metadata.recordCount'},
|
|
{name: 'comment', label: 'Description', path: 'metadata.comment', emptyText: '—'},
|
|
{name: 'id', label: 'Hosted zone ID', format: 'code'},
|
|
]
|
|
|
|
const zoneFilters: FieldSchema[] = [{name: 'search', label: 'Search', type: 'text', required: false}]
|
|
|
|
export function awsDnsSchema(): ServiceSchema {
|
|
return {
|
|
cloud: 'aws',
|
|
service: 'dns',
|
|
displayName: 'Amazon Route 53 hosted zones',
|
|
fields: [
|
|
{
|
|
name: 'name',
|
|
label: 'Domain name',
|
|
type: 'text',
|
|
required: true,
|
|
description: 'For example example.com. TheCloud does not resolve DNS: records are stored and returned by the Route 53 API.',
|
|
validation: {pattern: DNS_ZONE_NAME_PATTERN, message: 'Use a domain name such as example.com'},
|
|
},
|
|
{name: 'comment', label: 'Description', type: 'text', required: false},
|
|
{
|
|
name: 'vpcId',
|
|
label: 'VPC ID (private zone)',
|
|
type: 'text',
|
|
required: false,
|
|
description: 'Leave empty for a public zone. With a VPC ID the zone is private and answers only inside that VPC.',
|
|
validation: {pattern: '^vpc-[0-9a-f]{8,17}$', message: 'Use a VPC ID such as vpc-0abc1234'},
|
|
},
|
|
],
|
|
actions: ['list', 'create', 'delete', 'inspect'],
|
|
capabilities: {
|
|
resourceActions: [
|
|
{name: 'list', label: 'List hosted zones', enabled: true, status: 'available', runtimeRequired: true},
|
|
{name: 'create', label: 'Create hosted zone', enabled: true, status: 'available', runtimeRequired: true},
|
|
{name: 'delete', label: 'Delete hosted zone', enabled: true, status: 'available', runtimeRequired: true},
|
|
{name: 'inspect', label: 'Inspect hosted zone', enabled: true, status: 'available', runtimeRequired: true},
|
|
],
|
|
itemActions: [
|
|
{name: 'list', label: 'List records', enabled: true, status: 'available', runtimeRequired: true},
|
|
{name: 'put', label: 'Create or update a record', enabled: true, status: 'available', runtimeRequired: true},
|
|
{name: 'delete', label: 'Delete a record', enabled: true, status: 'available', runtimeRequired: true},
|
|
],
|
|
},
|
|
filters: zoneFilters,
|
|
columns: zoneColumns,
|
|
}
|
|
}
|
|
|
|
export function dnsSchemaFor(cloud: CloudProvider): ServiceSchema | null {
|
|
return cloud === 'aws' ? awsDnsSchema() : null
|
|
}
|