### Starting a Trivial Python 3 Web Server using SystemD Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ec2/README.html This example demonstrates how to use `InitService.systemd_config_file` and `InitService.enable` to create and start a SystemD service for a Python web server, along with dropping an example file. ```python # vpc: ec2.Vpc # instance_type: ec2.InstanceType ec2.Instance(self, "Instance", vpc=vpc, instance_type=instance_type, machine_image=ec2.MachineImage.latest_amazon_linux2023(), init=ec2.CloudFormationInit.from_elements( # Create a simple config file that runs a Python web server ec2.InitService.systemd_config_file("simpleserver", command="/usr/bin/python3 -m http.server 8080", cwd="/var/www/html" ), # Start the server using SystemD ec2.InitService.enable("simpleserver", service_manager=ec2.ServiceManager.SYSTEMD ), # Drop an example file to show the web server working ec2.InitFile.from_string("/var/www/html/index.html", "Hello! It\'s working!")) ) ``` -------------------------------- ### Instantiate QuickConnectConfigProperty Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_connect/CfnQuickConnect.html Example of how to instantiate the QuickConnectConfigProperty, including optional phone, queue, and user configurations. ```python from aws_cdk import aws_connect as connect quick_connect_config_property = connect.CfnQuickConnect.QuickConnectConfigProperty( quick_connect_type="quickConnectType", # the properties below are optional phone_config=connect.CfnQuickConnect.PhoneNumberQuickConnectConfigProperty( phone_number="phoneNumber" ), queue_config=connect.CfnQuickConnect.QueueQuickConnectConfigProperty( contact_flow_arn="contactFlowArn", queue_arn="queueArn" ), user_config=connect.CfnQuickConnect.UserQuickConnectConfigProperty( contact_flow_arn="contactFlowArn", user_arn="userArn" ) ) ``` -------------------------------- ### Example Usage Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_apigateway/Integration.html An example demonstrating how to set up an HTTP integration for a GET method on a resource and attach an IAM policy to allow invocation. ```APIDOC ```python # books: apigateway.Resource # iam_user: iam.User get_books = books.add_method("GET", apigateway.HttpIntegration("http://amazon.com"), authorization_type=apigateway.AuthorizationType.IAM ) iam_user.attach_inline_policy(iam.Policy(self, "AllowBooks", statements=[ iam.PolicyStatement( actions=["execute-api:Invoke"], effect=iam.Effect.ALLOW, resources=[ get_books.method_arn ] ) ] )) ``` ``` -------------------------------- ### Instantiate FileSystem Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk/FileSystem.html Example of how to instantiate the FileSystem class. Replace placeholder values with your specific requirements. ```python import aws_cdk as cdk file_system = cdk.FileSystem() ``` -------------------------------- ### Instantiate DatabaseInstance Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_docdb/DatabaseInstance.html Example of how to instantiate a DatabaseInstance. Ensure you replace placeholder values with your actual configuration. ```python import aws_cdk as cdk from aws_cdk import aws_docdb as docdb from aws_cdk import aws_ec2 as ec2 from aws_cdk import aws_rds as rds from aws_cdk.interfaces import aws_docdb as interfaces_docdb # ca_certificate: rds.CaCertificate # d_b_cluster_ref: interfaces_docdb.IDBClusterRef # instance_type: ec2.InstanceType database_instance = docdb.DatabaseInstance(self, "MyDatabaseInstance", cluster=d_b_cluster_ref, instance_type=instance_type, # the properties below are optional auto_minor_version_upgrade=False, availability_zone="availabilityZone", ca_certificate=ca_certificate, db_instance_name="dbInstanceName", enable_performance_insights=False, preferred_maintenance_window="preferredMaintenanceWindow", removal_policy=cdk.RemovalPolicy.DESTROY ) ``` -------------------------------- ### Start Docker Daemon on Ubuntu Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.cfn_property_mixins.aws_codebuild/CfnProjectPropsMixin.html Commands to start the Docker daemon on an Ubuntu-based image within the install phase of a CodeBuild buildspec. ```bash - nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://0.0.0.0:2375 --storage-driver=overlay& - timeout 15 sh -c "until docker info; do echo .; sleep 1; done" ``` -------------------------------- ### ResourceCollectionFilterProperty Tag Filtering Example Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.cfn_property_mixins.aws_devopsguru/CfnResourceCollectionPropsMixin.html Example of how to filter resources for a collection using AWS tags. The tag keys must start with 'Devops-guru-' and are case-sensitive. ```json { "Type": "AWS::DevOpsGuru::ResourceCollection", "Properties": { "Type": "AWS_TAGS", "ResourceCollectionFilter": { "TagFilters": [ { "AppBoundaryKey": "Devops-guru-application", "TagValues": [ "Production", "Staging" ] }, { "AppBoundaryKey": "Devops-guru-environment", "TagValues": [ "Production" ] } ] } } } ``` -------------------------------- ### Instantiate ConfigureNatOptions Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ec2/ConfigureNatOptions.html Example of how to instantiate the ConfigureNatOptions type. Ensure you replace placeholder values with your actual subnet and VPC objects. ```python from aws_cdk import aws_ec2 as ec2 # private_subnet: ec2.PrivateSubnet # public_subnet: ec2.PublicSubnet # vpc: ec2.Vpc configure_nat_options = ec2.ConfigureNatOptions( nat_subnets=[public_subnet], private_subnets=[private_subnet], vpc=vpc ) ``` -------------------------------- ### Instantiate QuickConnectConfigProperty Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.cfn_property_mixins.aws_connect/CfnQuickConnectPropsMixin.html Example of how to instantiate the QuickConnectConfigProperty class with phone, queue, and user configurations. Ensure to replace placeholder values with actual ARNs and phone numbers. ```python from aws_cdk.cfn_property_mixins import aws_connect as connect quick_connect_config_property = connect.CfnQuickConnectPropsMixin.QuickConnectConfigProperty( phone_config=connect.CfnQuickConnectPropsMixin.PhoneNumberQuickConnectConfigProperty( phone_number="phoneNumber" ), queue_config=connect.CfnQuickConnectPropsMixin.QueueQuickConnectConfigProperty( contact_flow_arn="contactFlowArn", queue_arn="queueArn" ), quick_connect_type="quickConnectType", user_config=connect.CfnQuickConnectPropsMixin.UserQuickConnectConfigProperty( contact_flow_arn="contactFlowArn", user_arn="userArn" ) ) ``` -------------------------------- ### Instantiate LaunchTemplateSpecialVersions Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ec2/LaunchTemplateSpecialVersions.html Instantiates the LaunchTemplateSpecialVersions class. This is a basic setup example. ```python from aws_cdk import aws_ec2 as ec2 launch_template_special_versions = ec2.LaunchTemplateSpecialVersions() ``` -------------------------------- ### Full Example: Lambda Request Authorizer Setup in AWS CDK (Python) Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_apigateway/README.html A comprehensive example demonstrating the setup of a Lambda function as a request authorizer and its integration with a RestApi in AWS CDK. It includes defining the Lambda function, RestApi, and two RequestAuthorizer instances with different identity sources. The example also shows how to attach these authorizers to API methods and includes sample curl commands for testing. ```python from aws_cdk.aws_apigateway import IntegrationResponse, MethodResponse, IntegrationResponse, MethodResponse import path as path import aws_cdk.aws_lambda as lambda_ from aws_cdk import App, Stack from aws_cdk.aws_apigateway import MockIntegration, PassthroughBehavior, RestApi, RequestAuthorizer, IdentitySource # Against the RestApi endpoint from the stack output, run # `curl -s -o /dev/null -w "%{http_code}" ` should return 401 # `curl -s -o /dev/null -w "%{http_code}" -H 'Authorization: deny' ?allow=yes` should return 403 # `curl -s -o /dev/null -w "%{http_code}" -H 'Authorization: allow' ?allow=yes` should return 200 app = App() stack = Stack(app, "RequestAuthorizerInteg") authorizer_fn = lambda_.Function(stack, "MyAuthorizerFunction", runtime=lambda_.Runtime.NODEJS_LATEST, handler="index.handler", code=lambda_.AssetCode.from_asset(path.join(__dirname, "integ.request-authorizer.handler")) ) restapi = RestApi(stack, "MyRestApi", cloud_watch_role=True) authorizer = RequestAuthorizer(stack, "MyAuthorizer", handler=authorizer_fn, identity_sources=[IdentitySource.header("Authorization"), IdentitySource.query_string("allow")] ) second_authorizer = RequestAuthorizer(stack, "MySecondAuthorizer", handler=authorizer_fn, identity_sources=[IdentitySource.header("Authorization"), IdentitySource.query_string("allow")] ) restapi.root.add_method("ANY", MockIntegration( integration_responses=[IntegrationResponse(status_code="200") ], passthrough_behavior=PassthroughBehavior.NEVER, request_templates={ "application/json": "{ \"statusCode\": 200 }" } ), method_responses=[MethodResponse(status_code="200") ], authorizer=authorizer ) restapi.root.resource_for_path("auth").add_method("ANY", MockIntegration( integration_responses=[IntegrationResponse(status_code="200") ], passthrough_behavior=PassthroughBehavior.NEVER, request_templates={ "application/json": "{ \"statusCode\": 200 }" } ), method_responses=[MethodResponse(status_code="200") ], authorizer=second_authorizer ) ``` -------------------------------- ### Instantiate DeployOptions in Python Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.cloud_assembly_schema/DeployOptions.html Demonstrates how to create an instance of DeployOptions in Python, setting various deployment configurations. ```python # The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.cloud_assembly_schema as cloud_assembly_schema deploy_options = cloud_assembly_schema.DeployOptions( all=False, app="app", asset_metadata=False, ca_bundle_path="caBundlePath", change_set_name="changeSetName", ci=False, color=False, concurrency=123, context={ "context_key": "context" }, debug=False, ec2_creds=False, exclusively=False, execute=False, force=False, ignore_errors=False, json=False, lookups=False, notices=False, notification_arns=["notificationArns"], output="output", outputs_file="outputsFile", parameters={ "parameters_key": "parameters" }, path_metadata=False, profile="profile", proxy="proxy", require_approval=cloud_assembly_schema.RequireApproval.NEVER, reuse_assets=["reuseAssets"], role_arn="roleArn", rollback=False, stacks=["stacks"], staging=False, strict=False, toolkit_stack_name="toolkitStackName", trace=False, use_previous_parameters=False, verbose=False, version_reporting=False ) ``` -------------------------------- ### InlineApiDefinition Example Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_apigateway/InlineApiDefinition.html This example demonstrates how to create an API Gateway API using an inline OpenAPI definition. It defines a simple GET endpoint for '/pets' that returns a mock response. ```APIDOC ## GET /pets ### Description Defines a GET endpoint for the '/pets' path. This endpoint is configured with a mock integration that returns a 200 status code. ### Method GET ### Endpoint /pets ### Request Body None ### Response #### Success Response (200) - **schema**: Empty Schema (object) ### Response Example ```json { "statusCode": 200 } ``` ``` -------------------------------- ### Instantiate InputDeviceSettingsProperty Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_medialive/CfnInput.html This example shows how to create an InputDeviceSettingsProperty object. Remember to substitute the placeholder 'id' with the correct unique ID for your input device. ```python from aws_cdk import aws_medialive as medialive input_device_settings_property = medialive.CfnInput.InputDeviceSettingsProperty( id="id" ) ``` -------------------------------- ### Instantiate MaintenanceCreateSettingsProperty Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.cfn_property_mixins.aws_medialive/CfnChannelPropsMixin.html Example of how to instantiate the MaintenanceCreateSettingsProperty class with maintenance day and start time. ```python from aws_cdk.cfn_property_mixins import aws_medialive as medialive maintenance_create_settings_property = medialive.CfnChannelPropsMixin.MaintenanceCreateSettingsProperty( maintenance_day="maintenanceDay", maintenance_start_time="maintenanceStartTime" ) ``` -------------------------------- ### Instantiate RootDirectoryProperty with CreationInfo Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.cfn_property_mixins.aws_efs/CfnAccessPointPropsMixin.html Example of how to instantiate the RootDirectoryProperty, including owner UID, GID, and permissions for the root directory. ```python from aws_cdk.cfn_property_mixins import aws_efs as efs root_directory_property = efs.CfnAccessPointPropsMixin.RootDirectoryProperty( creation_info=efs.CfnAccessPointPropsMixin.CreationInfoProperty( owner_gid="ownerGid", owner_uid="ownerUid", permissions="permissions" ), path="path" ) ``` -------------------------------- ### Instantiate PartitionKey Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_appsync/PartitionKey.html Example of how to instantiate the PartitionKey type. Replace placeholder values with your specific requirements. ```python # The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk import aws_appsync as appsync # assign: appsync.Assign partition_key = appsync.PartitionKey(assign) ``` -------------------------------- ### Instantiate BuiltInAttributes Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ecs/BuiltInAttributes.html Shows how to create an instance of the BuiltInAttributes class. This is a basic setup example. ```python from aws_cdk import aws_ecs as ecs built_in_attributes = ecs.BuiltInAttributes() ``` -------------------------------- ### HTTP Proxy Integration Example Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_apigatewayv2_integrations/README.html This example configures a route GET /books with an HTTP proxy integration to an external HTTP endpoint. ```python from aws_cdk.aws_apigatewayv2_integrations import HttpUrlIntegration books_integration = HttpUrlIntegration("BooksIntegration", "https://get-books-proxy.example.com") http_api = apigwv2.HttpApi(self, "HttpApi") http_api.add_routes( path="/books", methods=[apigwv2.HttpMethod.GET], integration=books_integration ) ``` -------------------------------- ### Instantiate PreviewConfigProperty Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_connectcampaignsv2/CfnCampaign.html Example of how to instantiate the PreviewConfigProperty class with required and optional parameters. Ensure to replace placeholder values with your specific configuration. ```python from aws_cdk import aws_connectcampaignsv2 as connectcampaignsv2 preview_config_property = connectcampaignsv2.CfnCampaign.PreviewConfigProperty( bandwidth_allocation=123, timeout_config=connectcampaignsv2.CfnCampaign.TimeoutConfigProperty( duration_in_seconds=123 ), # the properties below are optional agent_actions=["agentActions"] ) ``` -------------------------------- ### Instantiate ApplicationMaintenanceConfigurationProperty Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.cfn_property_mixins.aws_kinesisanalyticsv2/CfnApplicationPropsMixin.html Example of how to create an instance of ApplicationMaintenanceConfigurationProperty, setting the maintenance window start time. ```python from aws_cdk.cfn_property_mixins import aws_kinesisanalyticsv2 as kinesisanalyticsv2 application_maintenance_configuration_property = kinesisanalyticsv2.CfnApplicationPropsMixin.ApplicationMaintenanceConfigurationProperty( application_maintenance_window_start_time="applicationMaintenanceWindowStartTime" ) ``` -------------------------------- ### Instantiate EnvironmentOptions Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_appconfig/EnvironmentOptions.html Shows how to create an instance of EnvironmentOptions with various configuration parameters. ```python from aws_cdk import aws_appconfig as appconfig # monitor: appconfig.Monitor environment_options = appconfig.EnvironmentOptions( deletion_protection_check=appconfig.DeletionProtectionCheck.ACCOUNT_DEFAULT, description="description", environment_name="environmentName", monitors=[monitor] ) ``` -------------------------------- ### Instantiate RangeOverrideProperty Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.cfn_property_mixins.aws_customerprofiles/CfnSegmentDefinitionPropsMixin.html Demonstrates how to create an instance of RangeOverrideProperty with example values for end, start, and unit. ```python from aws_cdk.cfn_property_mixins import aws_customerprofiles as customerprofiles range_override_property = customerprofiles.CfnSegmentDefinitionPropsMixin.RangeOverrideProperty( end=123, start=123, unit="unit" ) ``` -------------------------------- ### Instantiate VpnGateway Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ec2/VpnGateway.html Example of how to instantiate a VpnGateway. Ensure to replace placeholder values with your specific configuration. ```python from aws_cdk import aws_ec2 as ec2 vpn_gateway = ec2.VpnGateway(self, "MyVpnGateway", type="type", # the properties below are optional amazon_side_asn=123 ) ``` -------------------------------- ### Instantiate InputSettingsProperty Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_medialive/CfnChannel.html Example of how to instantiate the InputSettingsProperty with various nested properties for audio, captions, and video. ```python # The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk import aws_medialive as medialive input_settings_property = medialive.CfnChannel.InputSettingsProperty( audio_selectors=[ medialive.CfnChannel.AudioSelectorProperty( name="name", selector_settings=medialive.CfnChannel.AudioSelectorSettingsProperty( audio_hls_rendition_selection=medialive.CfnChannel.AudioHlsRenditionSelectionProperty( group_id="groupId", name="name" ), audio_language_selection=medialive.CfnChannel.AudioLanguageSelectionProperty( language_code="languageCode", language_selection_policy="languageSelectionPolicy" ), audio_pid_selection=medialive.CfnChannel.AudioPidSelectionProperty( pid=123 ), audio_track_selection=medialive.CfnChannel.AudioTrackSelectionProperty( dolby_e_decode=medialive.CfnChannel.AudioDolbyEDecodeProperty( program_selection="programSelection" ), tracks=[ medialive.CfnChannel.AudioTrackProperty( track=123 ) ] ) ) ) ], caption_selectors=[ medialive.CfnChannel.CaptionSelectorProperty( language_code="languageCode", name="name", selector_settings=medialive.CfnChannel.CaptionSelectorSettingsProperty( ancillary_source_settings=medialive.CfnChannel.AncillarySourceSettingsProperty( source_ancillary_channel_number=123 ), arib_source_settings=medialive.CfnChannel.AribSourceSettingsProperty(), dvb_sub_source_settings=medialive.CfnChannel.DvbSubSourceSettingsProperty( ocr_language="ocrLanguage", pid=123 ), embedded_source_settings=medialive.CfnChannel.EmbeddedSourceSettingsProperty( convert608_to708="convert608To708", scte20_detection="scte20Detection", source608_channel_number=123, source608_track_number=123 ), scte20_source_settings=medialive.CfnChannel.Scte20SourceSettingsProperty( convert608_to708="convert608To708", source608_channel_number=123 ), scte27_source_settings=medialive.CfnChannel.Scte27SourceSettingsProperty( ocr_language="ocrLanguage", pid=123 ), teletext_source_settings=medialive.CfnChannel.TeletextSourceSettingsProperty( output_rectangle=medialive.CfnChannel.CaptionRectangleProperty( height=123, left_offset=123, top_offset=123, width=123 ), page_number="pageNumber" ) ) ) ], deblock_filter="deblockFilter", denoise_filter="denoiseFilter", filter_strength=123, input_filter="inputFilter", network_input_settings=medialive.CfnChannel.NetworkInputSettingsProperty( hls_input_settings=medialive.CfnChannel.HlsInputSettingsProperty( bandwidth=123, buffer_segments=123, retries=123, retry_interval=123, scte35_source="scte35Source" ), multicast_input_settings=medialive.CfnChannel.MulticastInputSettingsProperty( source_ip_address="sourceIpAddress" ), server_validation="serverValidation" ), scte35_pid=123, smpte2038_data_preference="smpte2038DataPreference", source_end_behavior="sourceEndBehavior", video_selector=medialive.CfnChannel.VideoSelectorProperty( color_space="colorSpace", color_space_settings=medialive.CfnChannel.VideoSelectorColorSpaceSettingsProperty( hdr10_settings=medialive.CfnChannel.Hdr10SettingsProperty( max_cll=123, max_fall=123 ) ), color_space_usage="colorSpaceUsage", selector_settings=medialive.CfnChannel.VideoSelectorSettingsProperty( video_selector_pid=medialive.CfnChannel.VideoSelectorPidProperty( pid=123 ), video_selector_program_id=medialive.CfnChannel.VideoSelectorProgramIdProperty( program_id=123 ) ) ) ) ``` -------------------------------- ### Instantiate X12ControlNumbersProperty Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_b2bi/CfnPartnership.html Example of how to instantiate the X12ControlNumbersProperty class with placeholder values for starting control numbers. ```python from aws_cdk import aws_b2bi as b2bi x12_control_numbers_property = b2bi.CfnPartnership.X12ControlNumbersProperty( starting_functional_group_control_number=123, starting_interchange_control_number=123, starting_transaction_set_control_number=123 ) ``` -------------------------------- ### CloudFront Distribution Configuration Example Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.cfn_property_mixins.aws_cloudfront/CfnDistributionPropsMixin.html Demonstrates how to configure a CloudFront distribution with various properties, including origins, tenant configuration, and viewer certificates. This example shows a complex setup with nested properties. ```python cloudfront.CfnDistributionPropsMixin.DistributionConfigProperty( aliases=["dnsName"], default_cache_behavior=cloudfront.CfnDistributionPropsMixin.CacheBehaviorProperty( allowed_methods=cloudfront.CfnDistributionPropsMixin.AllowedMethodsProperty( cached_methods=cloudfront.CfnDistributionPropsMixin.CachedMethodsProperty( http_methods=["GET", "HEAD", "OPTIONS"] ), methods=["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"] ), cache_policy=cloudfront.CfnDistributionPropsMixin.CachePolicyProperty( cache_policy_name="aws-managed-caching-policy" ), origin_request_policy=cloudfront.CfnDistributionPropsMixin.OriginRequestPolicyProperty( origin_request_policy_name="aws-managed-all-viewer" ), tunnel_identity=cloudfront.CfnDistributionPropsMixin.TunnelIdentityProperty( dns_name="dnsName", origin_access_identity="originAccessIdentity" ) ), default_root_object="index.html", enabled=True, origins=[ cloudfront.CfnDistributionPropsMixin.OriginProperty( domain_name="my-s3-bucket.s3.amazonaws.com", id="my-s3-origin", s3_origin_config=cloudfront.CfnDistributionPropsMixin.S3OriginConfigProperty( origin_access_identity="originAccessIdentity" ) ) ], staging=False, tenant_config=cloudfront.CfnDistributionPropsMixin.TenantConfigProperty( parameter_definitions=[ cloudfront.CfnDistributionPropsMixin.ParameterDefinitionProperty( name="name", definition=cloudfront.CfnDistributionPropsMixin.DefinitionProperty( string_schema=cloudfront.CfnDistributionPropsMixin.StringSchemaProperty( comment="comment", default_value="defaultValue", required=False ) ) ) ] ), viewer_certificate=cloudfront.CfnDistributionPropsMixin.ViewerCertificateProperty( acm_certificate_arn="acmCertificateArn", cloud_front_default_certificate=False, iam_certificate_id="iamCertificateId", minimum_protocol_version="minimumProtocolVersion", ssl_support_method="sslSupportMethod" ), viewer_mtls_config=cloudfront.CfnDistributionPropsMixin.ViewerMtlsConfigProperty( mode="mode", trust_store_config=cloudfront.CfnDistributionPropsMixin.TrustStoreConfigProperty( advertise_trust_store_ca_names=False, ignore_certificate_expiry=False, trust_store_id="trustStoreId" ) ), web_acl_id="webAclId" ) ``` -------------------------------- ### Instantiate PartitionKeyStep Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_appsync/PartitionKeyStep.html Demonstrates how to instantiate the PartitionKeyStep class. Replace placeholder values with your specific key. ```python from aws_cdk import aws_appsync as appsync partition_key_step = appsync.PartitionKeyStep("key") ``` -------------------------------- ### Instantiate RootDirectoryProperty Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_s3files/CfnAccessPoint.html Example of how to instantiate the RootDirectoryProperty with creation permissions and a path. Ensure to replace placeholder values with your actual configuration. ```python # The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk import aws_s3files as s3files root_directory_property = s3files.CfnAccessPoint.RootDirectoryProperty( creation_permissions=s3files.CfnAccessPoint.CreationPermissionsProperty( owner_gid="ownerGid", owner_uid="ownerUid", permissions="permissions" ), path="path" ) ``` -------------------------------- ### Instantiate ResponderGatewayReference Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.interfaces.aws_rtbfabric/ResponderGatewayReference.html Shows how to create an instance of ResponderGatewayReference by providing the ARN of the ResponderGateway resource. This is a basic setup example. ```python from aws_cdk.interfaces import aws_rtbfabric as interfaces_rtbfabric responder_gateway_reference = interfaces_rtbfabric.ResponderGatewayReference( responder_gateway_arn="responderGatewayArn" ) ``` -------------------------------- ### Applying CloudFormation Init with Options Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ec2/ApplyCloudFormationInitOptions.html Demonstrates a complex setup for CloudFormationInit using config sets, init configs, init files, init groups, init users, and applying specific init options like timeout and including URL/role arguments. ```python ec2.Instance(self, "Instance", vpc=vpc, instance_type=instance_type, machine_image=machine_image, # Showing the most complex setup, if you have simpler requirements # you can use `CloudFormationInit.fromElements()`. init=ec2.CloudFormationInit.from_config_sets( config_sets={ # Applies the configs below in this order "default": ["yumPreinstall", "config"] }, configs={ "yum_preinstall": ec2.InitConfig([ # Install an Amazon Linux package using yum ec2.InitPackage.yum("git") ]), "config": ec2.InitConfig([ # Create a JSON file from tokens (can also create other files) ec2.InitFile.from_object("/etc/stack.json", { "stack_id": Stack.of(self).stack_id, "stack_name": Stack.of(self).stack_name, "region": Stack.of(self).region }), # Create a group and user ec2.InitGroup.from_name("my-group"), ec2.InitUser.from_name("my-user"), # Install an RPM from the internet ec2.InitPackage.rpm("http://mirrors.ukfast.co.uk/sites/dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/r/rubygem-git-1.5.0-2.el8.noarch.rpm") ]) } ), init_options=ec2.ApplyCloudFormationInitOptions( # Optional, which configsets to activate (['default'] by default) config_sets=["default"], # Optional, how long the installation is expected to take (5 minutes by default) timeout=Duration.minutes(30), # Optional, whether to include the --url argument when running cfn-init and cfn-signal commands (false by default) include_url=True, # Optional, whether to include the --role argument when running cfn-init and cfn-signal commands (false by default) include_role=True ) ) ``` -------------------------------- ### Instantiate TimePeriodProperty Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.cfn_property_mixins.aws_braket/CfnSpendingLimitPropsMixin.html Example of how to instantiate the TimePeriodProperty for CfnSpendingLimitPropsMixin, specifying the start and end times for the spending limit period. ```python # The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.cfn_property_mixins import aws_braket as braket time_period_property = braket.CfnSpendingLimitPropsMixin.TimePeriodProperty( end_at="endAt", start_at="startAt" ) ``` -------------------------------- ### Instantiate ConfigurationOptions Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_appconfig/ConfigurationOptions.html Example of how to instantiate the ConfigurationOptions class with various parameters. Replace placeholder values with your specific configuration details. ```python from aws_cdk import aws_appconfig as appconfig from aws_cdk import aws_kms as kms from aws_cdk.interfaces import aws_appconfig as interfaces_appconfig # deployment_strategy_ref: interfaces_appconfig.IDeploymentStrategyRef # environment: appconfig.Environment # key: kms.Key # validator: appconfig.IValidator configuration_options = appconfig.ConfigurationOptions( deletion_protection_check=appconfig.DeletionProtectionCheck.ACCOUNT_DEFAULT, deployment_key=key, deployment_strategy=deployment_strategy_ref, deploy_to=[environment], description="description", name="name", type=appconfig.ConfigurationType.FREEFORM, validators=[validator] ) ``` -------------------------------- ### Instantiate CoverageTimeProperty Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ssmcontacts/CfnRotation.html Example of how to instantiate the CoverageTimeProperty class to define the start and end times for an on-call rotation shift. ```python from aws_cdk import aws_ssmcontacts as ssmcontacts coverage_time_property = ssmcontacts.CfnRotation.CoverageTimeProperty( end_time="endTime", start_time="startTime" ) ``` -------------------------------- ### Instantiate SourceConfigProperty Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_robomaker/CfnRobotApplication.html Example of how to create an instance of the SourceConfigProperty class. Replace placeholder values with your actual configuration details. ```python from aws_cdk import aws_robomaker as robomaker source_config_property = robomaker.CfnRobotApplication.SourceConfigProperty( architecture="architecture", s3_bucket="s3Bucket", s3_key="s3Key" ) ``` -------------------------------- ### Instantiate TimeRangeProperty Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_connectcampaignsv2/CfnCampaign.html Example of how to instantiate the TimeRangeProperty class. Replace placeholder values with your actual start and end times. ```python from aws_cdk import aws_connectcampaignsv2 as connectcampaignsv2 time_range_property = connectcampaignsv2.CfnCampaign.TimeRangeProperty( end_time="endTime", start_time="startTime" ) ``` -------------------------------- ### Instantiate ClientVpnRoute Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ec2/ClientVpnRoute.html Example of how to instantiate the ClientVpnRoute class. Replace placeholder values with your actual configuration. ```python from aws_cdk import aws_ec2 as ec2 # client_vpn_endpoint: ec2.ClientVpnEndpoint # client_vpn_route_target: ec2.ClientVpnRouteTarget client_vpn_route = ec2.ClientVpnRoute(self, "MyClientVpnRoute", cidr="cidr", target=client_vpn_route_target, # the properties below are optional client_vpn_endpoint=client_vpn_endpoint, description="description" ) ``` -------------------------------- ### CloudFormationExecuteChangeSetAction Example Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_codepipeline_actions/CloudFormationExecuteChangeSetActionProps.html Demonstrates the setup of a CodePipeline with Source, Deploy, and Approval stages. Includes CloudFormationCreateReplaceChangeSetAction, ManualApprovalAction, and CloudFormationExecuteChangeSetAction. ```typescript import * as codecommit from 'aws-cdk-lib/aws-codecommit'; import * as codepipeline from 'aws-cdk-lib/aws-codepipeline'; import * as cpactions from 'aws-cdk-lib/aws-codepipeline-actions'; import { App, Stack } from 'aws-cdk-lib'; const app = new App(); const stack = new Stack(app, 'PipelineStack'); // Source stage: read from repository const repo = new codecommit.Repository(stack, "TemplateRepo", { repository_name: "template-repo" } ); const source_output = codepipeline.Artifact.uniqueName(); const source = new cpactions.CodeCommitSourceAction({ action_name: "Source", repository: repo, output: source_output, trigger: cpactions.CodeCommitTrigger.POLL }); const source_stage = { stage_name: "Source", actions: [source] }; // Deployment stage: create and deploy changeset with manual approval const stack_name = "OurStack"; const change_set_name = "StagedChangeSet"; const prod_stage = { stage_name: "Deploy", actions: [ new cpactions.CloudFormationCreateReplaceChangeSetAction({ action_name: "PrepareChanges", stack_name: stack_name, change_set_name: change_set_name, admin_permissions: true, template_path: source_output.at_path("template.yaml"), run_order: 1 }), new cpactions.ManualApprovalAction({ action_name: "ApproveChanges", run_order: 2 }), new cpactions.CloudFormationExecuteChangeSetAction({ action_name: "ExecuteChanges", stack_name: stack_name, change_set_name: change_set_name, run_order: 3 }) ] }; new codepipeline.Pipeline(stack, "Pipeline", { cross_account_keys: true, stages: [source_stage, prod_stage ] } ); ``` -------------------------------- ### Multipart User Data Example Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ec2/README.html Example of creating multipart user data with two parts: one for configuring Docker options as a boot hook and another for executing setup commands. ```python boot_hook_conf = ec2.UserData.for_linux() boot_hook_conf.add_commands("cloud-init-per once docker_options echo 'OPTIONS=\"${OPTIONS}\" --storage-opt dm.basesize=40G\"' >> /etc/sysconfig/docker") setup_commands = ec2.UserData.for_linux() setup_commands.add_commands("sudo yum install awscli && echo Packages installed らと > /var/tmp/setup") multipart_user_data = ec2.MultipartUserData() # The docker has to be configured at early stage, so content type is overridden to boothook multipart_user_data.add_part(ec2.MultipartBody.from_user_data(boot_hook_conf, "text/cloud-boothook; charset=\"us-ascii\"")) # Execute the rest of setup multipart_user_data.add_part(ec2.MultipartBody.from_user_data(setup_commands)) ec2.LaunchTemplate(self, "", user_data=multipart_user_data, block_devices=[] ) ``` -------------------------------- ### Instantiate CfnApplicationMixinProps Source: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.cfn_property_mixins.aws_appconfig/CfnApplicationMixinProps.html Example of how to instantiate CfnApplicationMixinProps with description, name, and tags. Replace placeholder values with your actual configuration. ```python from aws_cdk import CfnTag # The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.cfn_property_mixins import aws_appconfig as appconfig cfn_application_mixin_props = appconfig.CfnApplicationMixinProps( description="description", name="name", tags=[CfnTag( key="key", value="value" )] ) ```