def update_endpoint(self, endpoint, certificate): options = endpoint.source.options account_number = self.get_option("accountNumber", options) # relies on the fact that region is included in DNS name region = get_region_from_dns(endpoint.dnsname) arn = iam.create_arn_from_cert(account_number, region, certificate.name) if endpoint.type == "elbv2": listener_arn = elb.get_listener_arn_from_endpoint( endpoint.name, endpoint.port, account_number=account_number, region=region, ) elb.attach_certificate_v2( listener_arn, endpoint.port, [{ "CertificateArn": arn }], account_number=account_number, region=region, ) else: elb.attach_certificate( endpoint.name, endpoint.port, arn, account_number=account_number, region=region, )
def upload(self, name, body, private_key, cert_chain, options, **kwargs): try: iam.upload_cert(find_value('accountNumber', options), name, body, private_key, cert_chain=cert_chain) except BotoServerError as e: if e.error_code != 'EntityAlreadyExists': raise Exception(e) e = find_value('elb', options) if e: elb.attach_certificate(kwargs['accountNumber'], ['region'], e['name'], e['port'], e['certificateId'])
def update_endpoint(self, endpoint, certificate): options = endpoint.source.options account_number = self.get_option("accountNumber", options) if endpoint.type == "cloudfront": cert = iam.get_certificate(certificate.name, account_number=account_number) if not cert: return None cert_id = cert["ServerCertificateMetadata"]["ServerCertificateId"] cloudfront.attach_certificate(endpoint.name, cert_id, account_number=account_number) return if endpoint.type not in ["elb", "elbv2"]: raise NotImplementedError() # relies on the fact that region is included in DNS name region = get_region_from_dns(endpoint.dnsname) if endpoint.registry_type == 'iam': arn = iam.create_arn_from_cert(account_number, region, certificate.name, endpoint.certificate_path) else: raise Exception( f"Lemur doesn't support rotating certificates on {endpoint.registry_type} registry" ) if endpoint.type == "elbv2": listener_arn = elb.get_listener_arn_from_endpoint( endpoint.name, endpoint.port, account_number=account_number, region=region, ) elb.attach_certificate_v2( listener_arn, endpoint.port, [{ "CertificateArn": arn }], account_number=account_number, region=region, ) elif endpoint.type == "elb": elb.attach_certificate( endpoint.name, endpoint.port, arn, account_number=account_number, region=region, )
def update_endpoint(self, endpoint, certificate): options = endpoint.source.options account_number = self.get_option('accountNumber', options) # relies on the fact that region is included in DNS name region = get_region_from_dns(endpoint.dnsname) arn = iam.create_arn_from_cert(account_number, region, certificate.name) elb.attach_certificate(endpoint.name, endpoint.port, arn, account_number=account_number, region=region)
def update_endpoint(self, endpoint, certificate): options = endpoint.source.options account_number = self.get_option('accountNumber', options) # relies on the fact that region is included in DNS name region = get_region_from_dns(endpoint.dnsname) arn = iam.create_arn_from_cert(account_number, region, certificate.name) if endpoint.type == 'elbv2': listener_arn = elb.get_listener_arn_from_endpoint(endpoint.name, endpoint.port, account_number=account_number, region=region) elb.attach_certificate_v2(listener_arn, endpoint.port, [{'CertificateArn': arn}], account_number=account_number, region=region) else: elb.attach_certificate(endpoint.name, endpoint.port, arn, account_number=account_number, region=region)
def upload(self, name, body, private_key, cert_chain, options, **kwargs): try: iam.upload_cert(self.get_option('accountNumber', options), name, body, private_key, cert_chain=cert_chain) except BotoServerError as e: if e.error_code != 'EntityAlreadyExists': raise Exception(e) e = self.get_option('elb', options) if e: attach_certificate(kwargs['accountNumber'], ['region'], e['name'], e['port'], e['certificateId'])
def upload(self, name, body, private_key, cert_chain, options, **kwargs): if private_key: try: iam.upload_cert(find_value('accountNumber', options), name, body, private_key, cert_chain=cert_chain) except BotoServerError as e: if e.error_code != 'EntityAlreadyExists': raise Exception(e) e = find_value('elb', options) if e: elb.attach_certificate(kwargs['accountNumber'], ['region'], e['name'], e['port'], e['certificateId']) else: raise Exception("Unable to upload to AWS, private key is required")
def update_endpoint(self, endpoint, certificate): options = endpoint.source.options account_number = self.get_option("accountNumber", options) # relies on the fact that region is included in DNS name region = get_region_from_dns(endpoint.dnsname) if endpoint.registry_type == 'iam': arn = iam.create_arn_from_cert(account_number, region, certificate.name, endpoint.certificate_path) else: raise Exception( f"Lemur doesn't support rotating certificates on {endpoint.registry_type} registry" ) return if endpoint.type == "elbv2": listener_arn = elb.get_listener_arn_from_endpoint( endpoint.name, endpoint.port, account_number=account_number, region=region, ) elb.attach_certificate_v2( listener_arn, endpoint.port, [{ "CertificateArn": arn }], account_number=account_number, region=region, ) else: elb.attach_certificate( endpoint.name, endpoint.port, arn, account_number=account_number, region=region, )