How to use verify_domain_identity method in localstack

Best Python code snippet using localstack_python

cdk_contact_api_stack.py

Source:cdk_contact_api_stack.py Github

copy

Full Screen

1import kix2from aws_cdk import (3 core,4 aws_lambda,5 aws_apigateway,6 aws_certificatemanager, aws_route53, aws_route53_targets, aws_iam)7import os8from aws_cdk.aws_iam import PolicyStatement9from aws_cdk.custom_resources import AwsCustomResource, AwsSdkCall, PhysicalResourceId, AwsCustomResourcePolicy10from services.master_stack import CDKMasterStack11def add_contact_api(stack: CDKMasterStack, project_name: str, domain: str, forwarding_email: str):12 module_path = os.path.dirname(__file__)13 lambda_path = os.path.join(module_path, "lambda")14 api_path = "contact"15 base_lambda = aws_lambda.Function(16 stack, 'ContactFormLambda',17 handler='lambda_handler.handler',18 runtime=aws_lambda.Runtime.PYTHON_3_7,19 environment={20 "TARGET_EMAIL": forwarding_email,21 "SENDER_EMAIL": f"contact@{domain}",22 "SENDER_NAME": f"{project_name.capitalize()}",23 "SENDER": f"{project_name.capitalize()} Contact Form <contact@{domain}>"24 },25 code=aws_lambda.Code.asset(lambda_path),26 )27 base_lambda.add_to_role_policy(aws_iam.PolicyStatement(28 effect=aws_iam.Effect.ALLOW,29 resources=["*"],30 actions=["ses:SendEmail", "ses:SendRawEmail"]))31 verify_domain_create_call = AwsSdkCall(service="SES",32 action="verifyDomainIdentity",33 parameters={"Domain": domain},34 physical_resource_id=PhysicalResourceId.from_response("VerificationToken"))35 policy_statement = PolicyStatement(actions=["ses:VerifyDomainIdentity"], resources=["*"])36 verify_domain_identity = AwsCustomResource(37 stack, "VerifyDomainIdentity",38 on_create=verify_domain_create_call,39 policy=AwsCustomResourcePolicy.from_statements(statements=[policy_statement])40 )41 aws_route53.TxtRecord(42 stack, "SESVerificationRecord",43 zone=stack.zone,44 record_name=f"_amazonses.{domain}",45 values=[verify_domain_identity.get_response_field("VerificationToken")]46 )...

Full Screen

Full Screen

ses_domain_identity.py

Source:ses_domain_identity.py Github

copy

Full Screen

...18 region = event['ResourceProperties']['Region']19 print('Region: ' + region)20 ses = boto3.client('ses', region_name=region)21 if request_type == 'Create':22 domain_identity = ses.verify_domain_identity(Domain=domain)23 response_data['VerificationToken'] = domain_identity['VerificationToken']24 elif request_type == 'Update':25 oldDomain = event['OldResourceProperties']['Domain']26 if oldDomain != domain:27 try:28 ses.delete_identity(Identity=oldDomain)29 except Exception as e:30 print(e)31 domain_identity = ses.verify_domain_identity(Domain=domain)32 response_data['VerificationToken'] = domain_identity['VerificationToken']33 elif request_type == 'Delete':34 ses.delete_identity(Identity=domain)35 print(response_data)36 cfnresponse.send(event, context, cfnresponse.SUCCESS, response_data)37 except Exception as e:38 print('Exception occured: ' + str(e))39 cfnresponse.send(event, context, cfnresponse.FAILED, response_data)...

Full Screen

Full Screen

ses_services.py

Source:ses_services.py Github

copy

Full Screen

...8 response = ses.verify_email_identity(9 EmailAddress = email_adrress10 )11 return response12def verify_domain_identity(ses,domain_name):13 response = ses.verify_domain_identity(14 Domain=domain_name15 )16 return response17def list_identities_address(ses,email_adrress,max_item):18 response = ses.list_identities(19 IdentityType = email_adrress,20 MaxItems=max_item21 )22 return response23 24def list_identities_domain(ses,domain_name, max_item):25 response = ses.list_identities(26 IdentityType = domain_name,27 MaxItems=max_item...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful