Best Python code snippet using localstack_python
lambda_function.py
Source:lambda_function.py  
...33        record = ResourceRecord(validation_option['ResourceRecord']['Name'],34                                validation_option['ResourceRecord']['Value'])35        self.log.info('describe successfully %s' % record)36        return record37    def request_certificate(self, domain: str) -> Union[ResourceRecord, str]:38        """register certificate to ALB(so needs Available ALB as a prerequisite).39        Args:40            domain (str): domain name of certificate41        Returns:42            Re: [description]43        """44        if not domain:45            return 'empty domain. skip to request certificate.'46        self.log.info('request certificate %s' % domain)47        certificate = self.acm.request_certificate(DomainName=domain,48                                                   ValidationMethod='DNS')49        self.log.info('certificate created %s' % domain)50        self.log.debug(certificate)51        certificate_arn = certificate['CertificateArn']52        try:53            resource_record = self.get_resource_record(certificate_arn)54        except Exception:55            msg = ('failed to describe certificate.'56                   ' certificate_arn: %s') % certificate_arn57            self.log.error(msg, exc_info=True)58            return 'failed to describe certificate. certificate_arn: %s'59        return resource_record60def lambda_handler(event, context):61    # create logger62    logger = logging.getLogger('lambda_handler')63    logger.setLevel(logging.INFO)64    logger.info('start to request certificate.')65    logger.info('%s' % event)66    if ('domain' not in event) or (not event['domain']):67        return {68            'statusCode': 400,69            'body': json.dumps('empty domain. skip to request certificate.')70        }71    acm_client = AcmClient()72    result = acm_client.request_certificate(event['domain'])73    status_code = 200 if type(result) == ResourceRecord else 500...acm_starter.py
Source:acm_starter.py  
...52        cert["Serial"] = str(cert.get("Serial") or "")53        return result54    describe_orig = acm_models.CertBundle.describe55    acm_models.CertBundle.describe = describe56    def wrap_request_certificate(backend):57        def request_certificate(self, domain_name, domain_validation_options, *args, **kwargs):58            cert_arn = request_certificate_orig(59                domain_name, domain_validation_options, *args, **kwargs60            )61            cert = self._certificates[cert_arn]62            if not hasattr(cert, "domain_validation_options"):63                cert.domain_validation_options = domain_validation_options64            return cert_arn65        request_certificate_orig = backend.request_certificate66        backend.request_certificate = types.MethodType(request_certificate, backend)67    for _, backend in acm_models.acm_backends.items():68        wrap_request_certificate(backend)69def start_acm(port=None, asynchronous=False, update_listener=None):70    port = port or config.PORT_ACM71    apply_patches()72    return start_moto_server(73        "acm",74        port,75        name="ACM",76        update_listener=update_listener,77        asynchronous=asynchronous,...urls.py
Source:urls.py  
1from django.conf.urls import url2from views import request_certificate3from views import update_certificate4urlpatterns = [5    url(r'^request_certificate$', request_certificate, name='request_certificate'),6    url(r'^update_certificate$', update_certificate, name='update_certificate')...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
