UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 2.09 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.IpInstance=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),instance_1=require("./instance"),service_1=require("./service"),servicediscovery_generated_1=require("./servicediscovery.generated");class IpInstance extends instance_1.InstanceBase{constructor(scope,id,props){super(scope,id);try{jsiiDeprecationWarnings.aws_cdk_lib_aws_servicediscovery_IpInstanceProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,IpInstance),error}const dnsRecordType=props.service.dnsRecordType;if(dnsRecordType===service_1.DnsRecordType.CNAME)throw new Error("Service must support `A`, `AAAA` or `SRV` records to register this instance type.");if(dnsRecordType===service_1.DnsRecordType.SRV){if(!props.port)throw new Error("A `port` must be specified for a service using a `SRV` record.");if(!props.ipv4&&!props.ipv6)throw new Error("At least `ipv4` or `ipv6` must be specified for a service using a `SRV` record.")}if(!props.ipv4&&(dnsRecordType===service_1.DnsRecordType.A||dnsRecordType===service_1.DnsRecordType.A_AAAA))throw new Error("An `ipv4` must be specified for a service using a `A` record.");if(!props.ipv6&&(dnsRecordType===service_1.DnsRecordType.AAAA||dnsRecordType===service_1.DnsRecordType.A_AAAA))throw new Error("An `ipv6` must be specified for a service using a `AAAA` record.");const port=props.port||80,resource=new servicediscovery_generated_1.CfnInstance(this,"Resource",{instanceAttributes:{AWS_INSTANCE_IPV4:props.ipv4,AWS_INSTANCE_IPV6:props.ipv6,AWS_INSTANCE_PORT:port.toString(),...props.customAttributes},instanceId:props.instanceId||this.uniqueInstanceId(),serviceId:props.service.serviceId});this.service=props.service,this.instanceId=resource.ref,this.ipv4=props.ipv4||"",this.ipv6=props.ipv6||"",this.port=port}}exports.IpInstance=IpInstance,_a=JSII_RTTI_SYMBOL_1,IpInstance[_a]={fqn:"aws-cdk-lib.aws_servicediscovery.IpInstance",version:"2.70.0"};