aws-cdk-lib 2.194.0__py3-none-any.whl → 2.196.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of aws-cdk-lib might be problematic. Click here for more details.
- aws_cdk/__init__.py +435 -20
- aws_cdk/_jsii/__init__.py +1 -1
- aws_cdk/_jsii/{aws-cdk-lib@2.194.0.jsii.tgz → aws-cdk-lib@2.196.0.jsii.tgz} +0 -0
- aws_cdk/aws_acmpca/__init__.py +1 -1
- aws_cdk/aws_amazonmq/__init__.py +2 -2
- aws_cdk/aws_apigateway/__init__.py +208 -70
- aws_cdk/aws_apigatewayv2/__init__.py +155 -24
- aws_cdk/aws_appconfig/__init__.py +24 -0
- aws_cdk/aws_applicationautoscaling/__init__.py +6 -0
- aws_cdk/aws_appmesh/__init__.py +42 -0
- aws_cdk/aws_appsync/__init__.py +92 -20
- aws_cdk/aws_autoscaling/__init__.py +24 -0
- aws_cdk/aws_backup/__init__.py +53 -14
- aws_cdk/aws_batch/__init__.py +72 -0
- aws_cdk/aws_bedrock/__init__.py +1201 -18
- aws_cdk/aws_budgets/__init__.py +569 -0
- aws_cdk/aws_certificatemanager/__init__.py +21 -0
- aws_cdk/aws_chatbot/__init__.py +6 -0
- aws_cdk/aws_cloudfront/__init__.py +277 -120
- aws_cdk/aws_cloudfront/experimental/__init__.py +6 -0
- aws_cdk/aws_cloudtrail/__init__.py +6 -0
- aws_cdk/aws_cloudwatch/__init__.py +18 -0
- aws_cdk/aws_cloudwatch_actions/__init__.py +75 -1
- aws_cdk/aws_codebuild/__init__.py +48 -0
- aws_cdk/aws_codecommit/__init__.py +6 -0
- aws_cdk/aws_codedeploy/__init__.py +63 -0
- aws_cdk/aws_codeguruprofiler/__init__.py +6 -0
- aws_cdk/aws_codepipeline/__init__.py +114 -0
- aws_cdk/aws_codepipeline_actions/__init__.py +4 -4
- aws_cdk/aws_codestarnotifications/__init__.py +6 -0
- aws_cdk/aws_cognito/__init__.py +215 -10
- aws_cdk/aws_cognito_identitypool/__init__.py +6 -0
- aws_cdk/aws_config/__init__.py +36 -0
- aws_cdk/aws_datazone/__init__.py +1013 -100
- aws_cdk/aws_docdb/__init__.py +27 -3
- aws_cdk/aws_dsql/__init__.py +29 -12
- aws_cdk/aws_dynamodb/__init__.py +25 -11
- aws_cdk/aws_ec2/__init__.py +408 -23
- aws_cdk/aws_ecr/__init__.py +22 -14
- aws_cdk/aws_ecr_assets/__init__.py +6 -0
- aws_cdk/aws_ecs/__init__.py +116 -34
- aws_cdk/aws_ecs_patterns/__init__.py +58 -0
- aws_cdk/aws_efs/__init__.py +12 -0
- aws_cdk/aws_eks/__init__.py +42 -0
- aws_cdk/aws_elasticloadbalancing/__init__.py +6 -0
- aws_cdk/aws_elasticloadbalancingv2/__init__.py +112 -9
- aws_cdk/aws_elasticsearch/__init__.py +9 -0
- aws_cdk/aws_events/__init__.py +36 -0
- aws_cdk/aws_events_targets/__init__.py +10 -10
- aws_cdk/aws_fsx/__init__.py +8 -3
- aws_cdk/aws_globalaccelerator/__init__.py +18 -0
- aws_cdk/aws_iam/__init__.py +66 -0
- aws_cdk/aws_imagebuilder/__init__.py +181 -26
- aws_cdk/aws_inspector/__init__.py +6 -0
- aws_cdk/aws_kinesis/__init__.py +19 -1
- aws_cdk/aws_kinesisanalytics/__init__.py +7 -7
- aws_cdk/aws_kinesisanalyticsv2/__init__.py +7 -7
- aws_cdk/aws_kinesisfirehose/__init__.py +6 -0
- aws_cdk/aws_kms/__init__.py +16 -4
- aws_cdk/aws_lambda/__init__.py +76 -6
- aws_cdk/aws_lambda_nodejs/__init__.py +6 -0
- aws_cdk/aws_logs/__init__.py +155 -12
- aws_cdk/aws_medialive/__init__.py +4 -6
- aws_cdk/aws_mediatailor/__init__.py +115 -0
- aws_cdk/aws_oam/__init__.py +43 -10
- aws_cdk/aws_opensearchservice/__init__.py +12 -0
- aws_cdk/aws_qbusiness/__init__.py +2 -2
- aws_cdk/aws_quicksight/__init__.py +22 -22
- aws_cdk/aws_rds/__init__.py +347 -36
- aws_cdk/aws_redshiftserverless/__init__.py +7 -7
- aws_cdk/aws_route53/__init__.py +735 -33
- aws_cdk/aws_route53_targets/__init__.py +62 -1
- aws_cdk/aws_route53profiles/__init__.py +1 -1
- aws_cdk/aws_s3/__init__.py +37 -10
- aws_cdk/aws_s3_deployment/__init__.py +6 -0
- aws_cdk/aws_s3_notifications/__init__.py +5 -5
- aws_cdk/aws_sagemaker/__init__.py +452 -8
- aws_cdk/aws_scheduler/__init__.py +12 -0
- aws_cdk/aws_secretsmanager/__init__.py +24 -0
- aws_cdk/aws_servicecatalog/__init__.py +24 -0
- aws_cdk/aws_servicediscovery/__init__.py +48 -0
- aws_cdk/aws_ses/__init__.py +133 -33
- aws_cdk/aws_signer/__init__.py +6 -0
- aws_cdk/aws_sns/__init__.py +18 -0
- aws_cdk/aws_sns_subscriptions/__init__.py +6 -0
- aws_cdk/aws_sqs/__init__.py +12 -0
- aws_cdk/aws_ssm/__init__.py +12 -0
- aws_cdk/aws_ssmcontacts/__init__.py +53 -2
- aws_cdk/aws_ssmguiconnect/__init__.py +544 -0
- aws_cdk/aws_stepfunctions/__init__.py +153 -7
- aws_cdk/aws_stepfunctions_tasks/__init__.py +46 -10
- aws_cdk/aws_synthetics/__init__.py +32 -0
- aws_cdk/aws_verifiedpermissions/__init__.py +168 -3
- aws_cdk/aws_vpclattice/__init__.py +3 -1
- aws_cdk/aws_wisdom/__init__.py +6 -4
- aws_cdk/cloud_assembly_schema/__init__.py +7 -1
- aws_cdk/custom_resources/__init__.py +18 -0
- aws_cdk/cx_api/__init__.py +33 -0
- aws_cdk/lambda_layer_awscli/__init__.py +6 -0
- aws_cdk/lambda_layer_node_proxy_agent/__init__.py +6 -0
- aws_cdk/pipelines/__init__.py +10 -10
- aws_cdk/triggers/__init__.py +6 -0
- {aws_cdk_lib-2.194.0.dist-info → aws_cdk_lib-2.196.0.dist-info}/METADATA +84 -6
- {aws_cdk_lib-2.194.0.dist-info → aws_cdk_lib-2.196.0.dist-info}/RECORD +108 -107
- {aws_cdk_lib-2.194.0.dist-info → aws_cdk_lib-2.196.0.dist-info}/LICENSE +0 -0
- {aws_cdk_lib-2.194.0.dist-info → aws_cdk_lib-2.196.0.dist-info}/NOTICE +0 -0
- {aws_cdk_lib-2.194.0.dist-info → aws_cdk_lib-2.196.0.dist-info}/WHEEL +0 -0
- {aws_cdk_lib-2.194.0.dist-info → aws_cdk_lib-2.196.0.dist-info}/top_level.txt +0 -0
aws_cdk/cx_api/__init__.py
CHANGED
|
@@ -718,6 +718,39 @@ resource lambda function logs.
|
|
|
718
718
|
}
|
|
719
719
|
}
|
|
720
720
|
```
|
|
721
|
+
|
|
722
|
+
* `@aws-cdk/aws-s3:publicAccessBlockedByDefault`
|
|
723
|
+
|
|
724
|
+
When BlockPublicAccess is not set at all, s3's default behavior will be to set all options to true in aws console.
|
|
725
|
+
The previous behavior in cdk before this feature was; if only some of the BlockPublicAccessOptions were set (not all 4), then the ones undefined would default to false.
|
|
726
|
+
This is counter intuitive to the console behavior where the options would start in true state and a user would uncheck the boxes as needed.
|
|
727
|
+
The new behavior from this feature will allow a user, for example, to set 1 of the 4 BlockPublicAccessOpsions to false, and on deployment the other 3 will remain true.
|
|
728
|
+
|
|
729
|
+
*cdk.json*
|
|
730
|
+
|
|
731
|
+
```json
|
|
732
|
+
{
|
|
733
|
+
"context": {
|
|
734
|
+
"@aws-cdk/aws-s3:publicAccessBlockedByDefault": true
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
```
|
|
738
|
+
|
|
739
|
+
* `@aws-cdk/aws-ec2:requirePrivateSubnetsForEgressOnlyInternetGateway`
|
|
740
|
+
|
|
741
|
+
When this feature flag is enabled, EgressOnlyGateway is created only for dual-stack VPC with private subnets
|
|
742
|
+
|
|
743
|
+
When this feature flag is disabled, EgressOnlyGateway resource is created for all dual-stack VPC regardless of subnet type
|
|
744
|
+
|
|
745
|
+
*cdk.json*
|
|
746
|
+
|
|
747
|
+
```json
|
|
748
|
+
{
|
|
749
|
+
"context": {
|
|
750
|
+
"@aws-cdk/aws-ec2:requirePrivateSubnetsForEgressOnlyInternetGateway": true
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
```
|
|
721
754
|
'''
|
|
722
755
|
from pkgutil import extend_path
|
|
723
756
|
__path__ = extend_path(__path__, __name__)
|
|
@@ -89,6 +89,12 @@ class AwsCliLayer(
|
|
|
89
89
|
check_type(argname="argument id", value=id, expected_type=type_hints["id"])
|
|
90
90
|
jsii.create(self.__class__, self, [scope, id])
|
|
91
91
|
|
|
92
|
+
@jsii.python.classproperty
|
|
93
|
+
@jsii.member(jsii_name="PROPERTY_INJECTION_ID")
|
|
94
|
+
def PROPERTY_INJECTION_ID(cls) -> builtins.str:
|
|
95
|
+
'''Uniquely identifies this class.'''
|
|
96
|
+
return typing.cast(builtins.str, jsii.sget(cls, "PROPERTY_INJECTION_ID"))
|
|
97
|
+
|
|
92
98
|
|
|
93
99
|
__all__ = [
|
|
94
100
|
"AwsCliLayer",
|
|
@@ -84,6 +84,12 @@ class NodeProxyAgentLayer(
|
|
|
84
84
|
check_type(argname="argument id", value=id, expected_type=type_hints["id"])
|
|
85
85
|
jsii.create(self.__class__, self, [scope, id])
|
|
86
86
|
|
|
87
|
+
@jsii.python.classproperty
|
|
88
|
+
@jsii.member(jsii_name="PROPERTY_INJECTION_ID")
|
|
89
|
+
def PROPERTY_INJECTION_ID(cls) -> builtins.str:
|
|
90
|
+
'''Uniquely identifies this class.'''
|
|
91
|
+
return typing.cast(builtins.str, jsii.sget(cls, "PROPERTY_INJECTION_ID"))
|
|
92
|
+
|
|
87
93
|
|
|
88
94
|
__all__ = [
|
|
89
95
|
"NodeProxyAgentLayer",
|
aws_cdk/pipelines/__init__.py
CHANGED
|
@@ -70,8 +70,8 @@ class ComputeStack(Stack):
|
|
|
70
70
|
# Stack to hold the pipeline
|
|
71
71
|
#
|
|
72
72
|
class MyPipelineStack(Stack):
|
|
73
|
-
def __init__(self, scope, id, *, description=None, env=None, stackName=None, tags=None, notificationArns=None, synthesizer=None, terminationProtection=None, analyticsReporting=None, crossRegionReferences=None, permissionsBoundary=None, suppressTemplateIndentation=None):
|
|
74
|
-
super().__init__(scope, id, description=description, env=env, stackName=stackName, tags=tags, notificationArns=notificationArns, synthesizer=synthesizer, terminationProtection=terminationProtection, analyticsReporting=analyticsReporting, crossRegionReferences=crossRegionReferences, permissionsBoundary=permissionsBoundary, suppressTemplateIndentation=suppressTemplateIndentation)
|
|
73
|
+
def __init__(self, scope, id, *, description=None, env=None, stackName=None, tags=None, notificationArns=None, synthesizer=None, terminationProtection=None, analyticsReporting=None, crossRegionReferences=None, permissionsBoundary=None, suppressTemplateIndentation=None, propertyInjectors=None):
|
|
74
|
+
super().__init__(scope, id, description=description, env=env, stackName=stackName, tags=tags, notificationArns=notificationArns, synthesizer=synthesizer, terminationProtection=terminationProtection, analyticsReporting=analyticsReporting, crossRegionReferences=crossRegionReferences, permissionsBoundary=permissionsBoundary, suppressTemplateIndentation=suppressTemplateIndentation, propertyInjectors=propertyInjectors)
|
|
75
75
|
|
|
76
76
|
pipeline = pipelines.CodePipeline(self, "Pipeline",
|
|
77
77
|
synth=pipelines.ShellStep("Synth",
|
|
@@ -104,8 +104,8 @@ class MyPipelineStack(Stack):
|
|
|
104
104
|
# we make sure they are deployed together, or not at all.
|
|
105
105
|
#
|
|
106
106
|
class MyApplication(Stage):
|
|
107
|
-
def __init__(self, scope, id, *, env=None, outdir=None, stageName=None, permissionsBoundary=None, policyValidationBeta1=None):
|
|
108
|
-
super().__init__(scope, id, env=env, outdir=outdir, stageName=stageName, permissionsBoundary=permissionsBoundary, policyValidationBeta1=policyValidationBeta1)
|
|
107
|
+
def __init__(self, scope, id, *, env=None, outdir=None, stageName=None, permissionsBoundary=None, policyValidationBeta1=None, propertyInjectors=None):
|
|
108
|
+
super().__init__(scope, id, env=env, outdir=outdir, stageName=stageName, permissionsBoundary=permissionsBoundary, policyValidationBeta1=policyValidationBeta1, propertyInjectors=propertyInjectors)
|
|
109
109
|
|
|
110
110
|
db_stack = DatabaseStack(self, "Database")
|
|
111
111
|
ComputeStack(self, "Compute",
|
|
@@ -512,8 +512,8 @@ The creation of change sets can be switched off by setting `useChangeSets: false
|
|
|
512
512
|
|
|
513
513
|
|
|
514
514
|
class PipelineStack(Stack):
|
|
515
|
-
def __init__(self, scope, id, *, description=None, env=None, stackName=None, tags=None, notificationArns=None, synthesizer=None, terminationProtection=None, analyticsReporting=None, crossRegionReferences=None, permissionsBoundary=None, suppressTemplateIndentation=None):
|
|
516
|
-
super().__init__(scope, id, description=description, env=env, stackName=stackName, tags=tags, notificationArns=notificationArns, synthesizer=synthesizer, terminationProtection=terminationProtection, analyticsReporting=analyticsReporting, crossRegionReferences=crossRegionReferences, permissionsBoundary=permissionsBoundary, suppressTemplateIndentation=suppressTemplateIndentation)
|
|
515
|
+
def __init__(self, scope, id, *, description=None, env=None, stackName=None, tags=None, notificationArns=None, synthesizer=None, terminationProtection=None, analyticsReporting=None, crossRegionReferences=None, permissionsBoundary=None, suppressTemplateIndentation=None, propertyInjectors=None):
|
|
516
|
+
super().__init__(scope, id, description=description, env=env, stackName=stackName, tags=tags, notificationArns=notificationArns, synthesizer=synthesizer, terminationProtection=terminationProtection, analyticsReporting=analyticsReporting, crossRegionReferences=crossRegionReferences, permissionsBoundary=permissionsBoundary, suppressTemplateIndentation=suppressTemplateIndentation, propertyInjectors=propertyInjectors)
|
|
517
517
|
|
|
518
518
|
pipeline = pipelines.CodePipeline(self, "Pipeline",
|
|
519
519
|
synth=synth,
|
|
@@ -559,8 +559,8 @@ You can also specify steps to be executed at the stack level. To achieve this, y
|
|
|
559
559
|
# pipeline: pipelines.CodePipeline
|
|
560
560
|
class MyStacksStage(Stage):
|
|
561
561
|
|
|
562
|
-
def __init__(self, scope, id, *, env=None, outdir=None, stageName=None, permissionsBoundary=None, policyValidationBeta1=None):
|
|
563
|
-
super().__init__(scope, id, env=env, outdir=outdir, stageName=stageName, permissionsBoundary=permissionsBoundary, policyValidationBeta1=policyValidationBeta1)
|
|
562
|
+
def __init__(self, scope, id, *, env=None, outdir=None, stageName=None, permissionsBoundary=None, policyValidationBeta1=None, propertyInjectors=None):
|
|
563
|
+
super().__init__(scope, id, env=env, outdir=outdir, stageName=stageName, permissionsBoundary=permissionsBoundary, policyValidationBeta1=policyValidationBeta1, propertyInjectors=propertyInjectors)
|
|
564
564
|
self.stack1 = Stack(self, "stack1")
|
|
565
565
|
self.stack2 = Stack(self, "stack2")
|
|
566
566
|
prod = MyStacksStage(self, "Prod")
|
|
@@ -613,8 +613,8 @@ pass it to `envFromCfnOutputs` of the `ShellStep`:
|
|
|
613
613
|
# pipeline: pipelines.CodePipeline
|
|
614
614
|
class MyOutputStage(Stage):
|
|
615
615
|
|
|
616
|
-
def __init__(self, scope, id, *, env=None, outdir=None, stageName=None, permissionsBoundary=None, policyValidationBeta1=None):
|
|
617
|
-
super().__init__(scope, id, env=env, outdir=outdir, stageName=stageName, permissionsBoundary=permissionsBoundary, policyValidationBeta1=policyValidationBeta1)
|
|
616
|
+
def __init__(self, scope, id, *, env=None, outdir=None, stageName=None, permissionsBoundary=None, policyValidationBeta1=None, propertyInjectors=None):
|
|
617
|
+
super().__init__(scope, id, env=env, outdir=outdir, stageName=stageName, permissionsBoundary=permissionsBoundary, policyValidationBeta1=policyValidationBeta1, propertyInjectors=propertyInjectors)
|
|
618
618
|
self.load_balancer_address = CfnOutput(self, "Output",
|
|
619
619
|
value="value"
|
|
620
620
|
)
|
aws_cdk/triggers/__init__.py
CHANGED
|
@@ -620,6 +620,12 @@ class TriggerFunction(
|
|
|
620
620
|
check_type(argname="argument scopes", value=scopes, expected_type=typing.Tuple[type_hints["scopes"], ...]) # pyright: ignore [reportGeneralTypeIssues]
|
|
621
621
|
return typing.cast(None, jsii.invoke(self, "executeBefore", [*scopes]))
|
|
622
622
|
|
|
623
|
+
@jsii.python.classproperty
|
|
624
|
+
@jsii.member(jsii_name="PROPERTY_INJECTION_ID")
|
|
625
|
+
def PROPERTY_INJECTION_ID(cls) -> builtins.str:
|
|
626
|
+
'''Uniquely identifies this class.'''
|
|
627
|
+
return typing.cast(builtins.str, jsii.sget(cls, "PROPERTY_INJECTION_ID"))
|
|
628
|
+
|
|
623
629
|
@builtins.property
|
|
624
630
|
@jsii.member(jsii_name="trigger")
|
|
625
631
|
def trigger(self) -> Trigger:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: aws-cdk-lib
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.196.0
|
|
4
4
|
Summary: Version 2 of the AWS Cloud Development Kit library
|
|
5
5
|
Home-page: https://github.com/aws/aws-cdk
|
|
6
6
|
Author: Amazon Web Services
|
|
@@ -20,11 +20,11 @@ Requires-Python: ~=3.9
|
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
License-File: LICENSE
|
|
22
22
|
License-File: NOTICE
|
|
23
|
-
Requires-Dist: aws-cdk.asset-awscli-v1
|
|
23
|
+
Requires-Dist: aws-cdk.asset-awscli-v1==2.2.236
|
|
24
24
|
Requires-Dist: aws-cdk.asset-node-proxy-agent-v6<3.0.0,>=2.1.0
|
|
25
|
-
Requires-Dist: aws-cdk.cloud-assembly-schema<42.0.0,>=41.
|
|
25
|
+
Requires-Dist: aws-cdk.cloud-assembly-schema<42.0.0,>=41.2.0
|
|
26
26
|
Requires-Dist: constructs<11.0.0,>=10.0.0
|
|
27
|
-
Requires-Dist: jsii<2.0.0,>=1.
|
|
27
|
+
Requires-Dist: jsii<2.0.0,>=1.112.0
|
|
28
28
|
Requires-Dist: publication>=0.0.3
|
|
29
29
|
Requires-Dist: typeguard<4.3.0,>=2.13.3
|
|
30
30
|
|
|
@@ -202,8 +202,8 @@ class MyNestedStack(cfn.NestedStack):
|
|
|
202
202
|
s3.Bucket(self, "NestedBucket")
|
|
203
203
|
|
|
204
204
|
class MyParentStack(Stack):
|
|
205
|
-
def __init__(self, scope, id, *, description=None, env=None, stackName=None, tags=None, notificationArns=None, synthesizer=None, terminationProtection=None, analyticsReporting=None, crossRegionReferences=None, permissionsBoundary=None, suppressTemplateIndentation=None):
|
|
206
|
-
super().__init__(scope, id, description=description, env=env, stackName=stackName, tags=tags, notificationArns=notificationArns, synthesizer=synthesizer, terminationProtection=terminationProtection, analyticsReporting=analyticsReporting, crossRegionReferences=crossRegionReferences, permissionsBoundary=permissionsBoundary, suppressTemplateIndentation=suppressTemplateIndentation)
|
|
205
|
+
def __init__(self, scope, id, *, description=None, env=None, stackName=None, tags=None, notificationArns=None, synthesizer=None, terminationProtection=None, analyticsReporting=None, crossRegionReferences=None, permissionsBoundary=None, suppressTemplateIndentation=None, propertyInjectors=None):
|
|
206
|
+
super().__init__(scope, id, description=description, env=env, stackName=stackName, tags=tags, notificationArns=notificationArns, synthesizer=synthesizer, terminationProtection=terminationProtection, analyticsReporting=analyticsReporting, crossRegionReferences=crossRegionReferences, permissionsBoundary=permissionsBoundary, suppressTemplateIndentation=suppressTemplateIndentation, propertyInjectors=propertyInjectors)
|
|
207
207
|
|
|
208
208
|
MyNestedStack(self, "Nested1")
|
|
209
209
|
MyNestedStack(self, "Nested2")
|
|
@@ -1528,4 +1528,82 @@ warning by the `id`.
|
|
|
1528
1528
|
Annotations.of(self).acknowledge_warning("IAM:Group:MaxPoliciesExceeded", "Account has quota increased to 20")
|
|
1529
1529
|
```
|
|
1530
1530
|
|
|
1531
|
+
## Blueprint Property Injection
|
|
1532
|
+
|
|
1533
|
+
The goal of Blueprint Property Injection is to provide builders an automatic way to set default property values.
|
|
1534
|
+
|
|
1535
|
+
Construct authors can declare that a Construct can have it properties injected by adding `@propertyInjectable`
|
|
1536
|
+
class decorator and specifying `PROPERTY_INJECTION_ID` readonly property.
|
|
1537
|
+
All L2 Constructs will support Property Injection so organizations can write injectors to set their Construct Props.
|
|
1538
|
+
|
|
1539
|
+
Organizations can set default property values to a Construct by writing Injectors for builders to consume.
|
|
1540
|
+
|
|
1541
|
+
Here is a simple example of an Injector for APiKey that sets enabled to false.
|
|
1542
|
+
|
|
1543
|
+
```python
|
|
1544
|
+
@jsii.implements(IPropertyInjector)
|
|
1545
|
+
class ApiKeyPropsInjector:
|
|
1546
|
+
|
|
1547
|
+
def __init__(self):
|
|
1548
|
+
self.construct_unique_id = api.ApiKey.PROPERTY_INJECTION_ID
|
|
1549
|
+
|
|
1550
|
+
def inject(self, original_props, *, scope, id):
|
|
1551
|
+
return api.ApiKeyProps(
|
|
1552
|
+
enabled=False,
|
|
1553
|
+
api_key_name=original_props.api_key_name,
|
|
1554
|
+
customer_id=original_props.customer_id,
|
|
1555
|
+
default_cors_preflight_options=original_props.default_cors_preflight_options,
|
|
1556
|
+
default_integration=original_props.default_integration,
|
|
1557
|
+
default_method_options=original_props.default_method_options,
|
|
1558
|
+
description=original_props.description,
|
|
1559
|
+
generate_distinct_id=original_props.generate_distinct_id,
|
|
1560
|
+
resources=original_props.resources,
|
|
1561
|
+
stages=original_props.stages,
|
|
1562
|
+
value=original_props.value
|
|
1563
|
+
)
|
|
1564
|
+
```
|
|
1565
|
+
|
|
1566
|
+
Some notes:
|
|
1567
|
+
|
|
1568
|
+
* ApiKey must have a `PROPERTY_INJECTION_ID` property, in addition to having `@propertyInjectable` class decorator.
|
|
1569
|
+
* We set ApiKeyProps.enabled to false, if it is not provided; otherwise it would use the value that was passed in.
|
|
1570
|
+
* It is also possible to force ApiKeyProps.enabled to false, and not provide a way for the builders to overwrite it.
|
|
1571
|
+
|
|
1572
|
+
Here is an example of how builders can use the injector the org created.
|
|
1573
|
+
|
|
1574
|
+
```python
|
|
1575
|
+
stack = Stack(app, "my-stack",
|
|
1576
|
+
property_injectors=[ApiKeyPropsInjector()]
|
|
1577
|
+
)
|
|
1578
|
+
api.ApiKey(stack, "my-api-key")
|
|
1579
|
+
```
|
|
1580
|
+
|
|
1581
|
+
This is equivalent to:
|
|
1582
|
+
|
|
1583
|
+
```python
|
|
1584
|
+
stack = Stack(app, "my-stack")
|
|
1585
|
+
api.ApiKey(stack, "my-api-key",
|
|
1586
|
+
enabled=False
|
|
1587
|
+
)
|
|
1588
|
+
```
|
|
1589
|
+
|
|
1590
|
+
Some notes:
|
|
1591
|
+
|
|
1592
|
+
* We attach the injectors to Stack in this example, but we can also attach them to App or Stage.
|
|
1593
|
+
* All the ApiKey created in the scope of stack will get `enabled: false`.
|
|
1594
|
+
* Builders can overwrite the default value with `new ApiKey(stack, 'my-api-key', {enabled: true});`
|
|
1595
|
+
|
|
1596
|
+
If you specify two or more injectors for the same Constructs, the last one is in effect. In the example below, `ApiKeyPropsInjector` will never be applied.
|
|
1597
|
+
|
|
1598
|
+
```python
|
|
1599
|
+
stack = Stack(app, "my-stack",
|
|
1600
|
+
property_injectors=[
|
|
1601
|
+
ApiKeyPropsInjector(),
|
|
1602
|
+
AnotherApiKeyPropsInjector()
|
|
1603
|
+
]
|
|
1604
|
+
)
|
|
1605
|
+
```
|
|
1606
|
+
|
|
1607
|
+
For more information, please see the [RFC](https://github.com/aws/aws-cdk-rfcs/blob/main/text/0693-property-injection.md).
|
|
1608
|
+
|
|
1531
1609
|
<!--END CORE DOCUMENTATION-->
|