Skip to content

Commit 2ecd9dd

Browse files
authored
feat(README.md): add python and java minimal deployment (#582)
* added python min deployment and removed initializers * fixed merge conflict * changed to v1 imports in deprecated constructs * added python min dep in new constructs * added java minimal deployment code * fixed java builder prop defintion * fixed indentation * fixed indentation * updated python minimal deployments * updated java minimal deployments * updated to correct prop in route53-apigateway * updated python minimal deployments * cast to type Any in python example * updated java minimal deployments * updated java minimal deployments * updated typescript minimal deployments * added viperlight ignore to README with fake account numbers * added viperlight ignore to README with fake account numbers * added v1 deprecated comments in v1 constructs * changed asset name in aws-lambda-sqs-lambda
1 parent 32d5d8c commit 2ecd9dd

File tree

68 files changed

+3430
-1115
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3430
-1115
lines changed

.viperlightignore

+14
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,16 @@ source/patterns/@aws-solutions-constructs/aws-alb-lambda/README.md:35
145145
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/alb-lambda.test.ts:27
146146
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/alb-lambda.test.ts:680
147147
# These are references to the us-east-1 ELBV2 account (publicly known)
148+
source/patterns/@aws-solutions-constructs/aws-route53-alb/test/integ.deployPrivateApi.expected.json:196
149+
source/patterns/@aws-solutions-constructs/aws-route53-alb/test/integ.deployPrivateApiExistingZone.expected.json:853
150+
source/patterns/@aws-solutions-constructs/aws-route53-alb/test/integ.deployPublicApiNewAlb.expected.json:191
151+
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.privateApiNewResources.expected.json:199
152+
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.publicApiNewResources.expected.json:202
153+
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.twoTargets.expected.json:202
154+
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.privateApiExistingResources.expected.json:1067
155+
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.publicApiExistingResources.expected.json:1067
156+
source/patterns/@aws-solutions-constructs/aws-alb-fargate/test/integ.all-new-two-targets.expected.json:1034
157+
source/patterns/@aws-solutions-constructs/aws-alb-fargate/test/integ.all-new-public-http.expected.json:1007
148158
source/patterns/@aws-solutions-constructs/aws-route53-alb/test/integ.deployPrivateApi.expected.json:242
149159
source/patterns/@aws-solutions-constructs/aws-route53-alb/test/integ.deployPrivateApiExistingZone.expected.json:899
150160
source/patterns/@aws-solutions-constructs/aws-route53-alb/test/integ.deployPublicApiNewAlb.expected.json:237
@@ -155,3 +165,7 @@ source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.privateApiEx
155165
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.publicApiExistingResources.expected.json:1113
156166
source/patterns/@aws-solutions-constructs/aws-alb-fargate/test/integ.all-new-two-targets.expected.json:1081
157167
source/patterns/@aws-solutions-constructs/aws-alb-fargate/test/integ.all-new-public-http.expected.json:1054
168+
source/patterns/@aws-solutions-constructs/aws-alb-fargate/README.md:78
169+
source/patterns/@aws-solutions-constructs/aws-alb-lambda/README.md:84
170+
source/patterns/@aws-solutions-constructs/aws-route53-alb/README.md:59
171+
source/patterns/@aws-solutions-constructs/aws-wafwebacl-alb/README.md:68

source/patterns/@aws-solutions-constructs/aws-alb-fargate/README.md

+81-22
Original file line numberDiff line numberDiff line change
@@ -24,41 +24,100 @@
2424

2525
This AWS Solutions Construct implements an an Application Load Balancer to an AWS Fargate service
2626

27-
Here is a minimal deployable pattern definition in Typescript:
27+
Here is a minimal deployable pattern definition:
2828

29+
Typescript
2930
``` typescript
30-
import { AlbToFargate, AlbToFargateProps } from '@aws-solutions-constructs/aws-alb-fargate';
31-
32-
// Obtain a pre-existing certificate from your account
33-
const certificate = acm.Certificate.fromCertificateArn(
34-
scope,
35-
'existing-cert',
36-
"arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012"
37-
);
38-
39-
const props: AlbToFargateProps = {
31+
import { Construct } from 'constructs';
32+
import { Stack, StackProps } from 'aws-cdk-lib';
33+
import { AlbToFargate, AlbToFargateProps } from '@aws-solutions-constructs/aws-alb-fargate';
34+
import * as acm from 'aws-cdk-lib/aws-certificatemanager';
35+
36+
const certificate = acm.Certificate.fromCertificateArn(
37+
this,
38+
'existing-cert',
39+
"arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012"
40+
);
41+
42+
const constructProps: AlbToFargateProps = {
4043
ecrRepositoryArn: "arn:aws:ecr:us-east-1:123456789012:repository/your-ecr-repo",
4144
ecrImageVersion: "latest",
4245
listenerProps: {
43-
certificates: [ certificate ]
46+
certificates: [certificate]
4447
},
4548
publicApi: true
46-
};
49+
};
4750

48-
new AlbToFargate(stack, 'new-construct', props);
51+
// Note - all alb constructs turn on ELB logging by default, so require that an environment including account
52+
// and region be provided when creating the stack
53+
//
54+
// new MyStack(app, 'id', {env: {account: '123456789012', region: 'us-east-1' }});
55+
new AlbToFargate(this, 'new-construct', constructProps);
4956
```
5057

51-
## Initializer
58+
Python
59+
``` python
60+
from aws_solutions_constructs.aws_alb_fargate import AlbToFargate, AlbToFargateProps
61+
from aws_cdk import (
62+
aws_certificatemanager as acm,
63+
aws_elasticloadbalancingv2 as alb,
64+
Stack
65+
)
66+
from constructs import Construct
67+
68+
# Obtain a pre-existing certificate from your account
69+
certificate = acm.Certificate.from_certificate_arn(
70+
self,
71+
'existing-cert',
72+
"arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012"
73+
)
74+
75+
# Note - all alb constructs turn on ELB logging by default, so require that an environment including account
76+
# and region be provided when creating the stack
77+
#
78+
# MyStack(app, 'id', env=cdk.Environment(account='679431688440', region='us-east-1'))
79+
AlbToFargate(self, 'new-construct',
80+
ecr_repository_arn="arn:aws:ecr:us-east-1:123456789012:repository/your-ecr-repo",
81+
ecr_image_version="latest",
82+
listener_props=alb.BaseApplicationListenerProps(
83+
certificates=[certificate],
84+
),
85+
public_api=True)
5286

53-
``` text
54-
new AlbToFargate(scope: Construct, id: string, props: AlbToFargateProps);
5587
```
5688

57-
_Parameters_
58-
59-
* scope [`Construct`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.Construct.html)
60-
* id `string`
61-
* props [`AlbToFargateProps`](#pattern-construct-props)
89+
Java
90+
``` java
91+
import software.constructs.Construct;
92+
import java.util.List;
93+
94+
import software.amazon.awscdk.Stack;
95+
import software.amazon.awscdk.StackProps;
96+
import software.amazon.awscdk.services.elasticloadbalancingv2.*;
97+
import software.amazon.awsconstructs.services.albfargate.*;
98+
99+
// The code that defines your stack goes here
100+
// Obtain a pre-existing certificate from your account
101+
ListenerCertificate listenerCertificate = ListenerCertificate
102+
.fromArn("arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012");
103+
104+
// Note - all alb constructs turn on ELB logging by default, so require that an environment including account
105+
// and region be provided when creating the stack
106+
//
107+
// new MyStack(app, "id", StackProps.builder()
108+
// .env(Environment.builder()
109+
// .account("123456789012")
110+
// .region("us-east-1")
111+
// .build());
112+
new AlbToFargate(this, "AlbToFargatePattern", new AlbToFargateProps.Builder()
113+
.ecrRepositoryArn("arn:aws:ecr:us-east-1:123456789012:repository/your-ecr-repo")
114+
.ecrImageVersion("latest")
115+
.listenerProps(new BaseApplicationListenerProps.Builder()
116+
.certificates(List.of(listenerCertificate))
117+
.build())
118+
.publicApi(true)
119+
.build());
120+
```
62121

63122
## Pattern Construct Props
64123

source/patterns/@aws-solutions-constructs/aws-alb-lambda/README.md

+100-30
Original file line numberDiff line numberDiff line change
@@ -24,42 +24,112 @@
2424

2525
This AWS Solutions Construct implements an an Application Load Balancer to an AWS Lambda function
2626

27-
Here is a minimal deployable pattern definition in Typescript:
27+
Here is a minimal deployable pattern definition:
2828

29+
Typescript
2930
``` typescript
30-
31-
// Obtain a pre-existing certificate from your account
32-
const certificate = acm.Certificate.fromCertificateArn(
33-
scope,
34-
'existing-cert',
35-
"arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012"
36-
);
37-
const props: AlbToLambdaProps = {
38-
lambdaFunctionProps: {
39-
code: lambda.Code.fromAsset(`${__dirname}/lambda`),
40-
runtime: lambda.Runtime.NODEJS_14_X,
41-
handler: 'index.handler'
42-
},
43-
listenerProps: {
44-
certificates: [ certificate ]
45-
},
46-
publicApi: true
47-
};
48-
new AlbToLambda(stack, 'new-construct', props);
49-
31+
import { Construct } from 'constructs';
32+
import { Stack, StackProps } from 'aws-cdk-lib';
33+
import { AlbToLambda, AlbToLambdaProps } from '@aws-solutions-constructs/aws-alb-lambda';
34+
import * as acm from 'aws-cdk-lib/aws-certificatemanager';
35+
import * as lambda from 'aws-cdk-lib/aws-lambda';
36+
37+
// Obtain a pre-existing certificate from your account
38+
const certificate = acm.Certificate.fromCertificateArn(
39+
this,
40+
'existing-cert',
41+
"arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012"
42+
);
43+
44+
const constructProps: AlbToLambdaProps = {
45+
lambdaFunctionProps: {
46+
code: lambda.Code.fromAsset(`lambda`),
47+
runtime: lambda.Runtime.NODEJS_14_X,
48+
handler: 'index.handler'
49+
},
50+
listenerProps: {
51+
certificates: [certificate]
52+
},
53+
publicApi: true
54+
};
55+
56+
// Note - all alb constructs turn on ELB logging by default, so require that an environment including account
57+
// and region be provided when creating the stack
58+
//
59+
// new MyStack(app, 'id', {env: {account: '123456789012', region: 'us-east-1' }});
60+
new AlbToLambda(this, 'new-construct', constructProps);
5061
```
5162

52-
## Initializer
53-
54-
``` text
55-
new AlbToLambda(scope: Construct, id: string, props: AlbToLambdaProps);
63+
Python
64+
``` python
65+
from aws_solutions_constructs.aws_alb_lambda import AlbToLambda, AlbToLambdaProps
66+
from aws_cdk import (
67+
aws_certificatemanager as acm,
68+
aws_lambda as _lambda,
69+
aws_elasticloadbalancingv2 as alb,
70+
Stack
71+
)
72+
from constructs import Construct
73+
74+
# Obtain a pre-existing certificate from your account
75+
certificate = acm.Certificate.from_certificate_arn(
76+
self,
77+
'existing-cert',
78+
"arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012"
79+
)
80+
81+
# Note - all alb constructs turn on ELB logging by default, so require that an environment including account
82+
# and region be provided when creating the stack
83+
#
84+
# MyStack(app, 'id', env=cdk.Environment(account='679431688440', region='us-east-1'))
85+
AlbToLambda(self, 'new-construct',
86+
lambda_function_props=_lambda.FunctionProps(
87+
runtime=_lambda.Runtime.PYTHON_3_7,
88+
code=_lambda.Code.from_asset('lambda'),
89+
handler='index.handler',
90+
),
91+
listener_props=alb.BaseApplicationListenerProps(
92+
certificates=[certificate]
93+
),
94+
public_api=True)
5695
```
5796

58-
_Parameters_
59-
60-
* scope [`Construct`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.Construct.html)
61-
* id `string`
62-
* props [`AlbToLambdaProps`](#pattern-construct-props)
97+
Java
98+
``` java
99+
import software.constructs.Construct;
100+
import java.util.List;
101+
102+
import software.amazon.awscdk.Stack;
103+
import software.amazon.awscdk.StackProps;
104+
import software.amazon.awscdk.services.elasticloadbalancingv2.*;
105+
import software.amazon.awscdk.services.lambda.*;
106+
import software.amazon.awscdk.services.lambda.Runtime;
107+
import software.amazon.awsconstructs.services.alblambda.*;
108+
109+
// Obtain a pre-existing certificate from your account
110+
ListenerCertificate listenerCertificate = ListenerCertificate
111+
.fromArn("arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012");
112+
113+
// Note - all alb constructs turn on ELB logging by default, so require that an environment including account
114+
// and region be provided when creating the stack
115+
//
116+
// new MyStack(app, "id", StackProps.builder()
117+
// .env(Environment.builder()
118+
// .account("123456789012")
119+
// .region("us-east-1")
120+
// .build());
121+
new AlbToLambda(this, "AlbToLambdaPattern", new AlbToLambdaProps.Builder()
122+
.lambdaFunctionProps(new FunctionProps.Builder()
123+
.runtime(Runtime.NODEJS_14_X)
124+
.code(Code.fromAsset("lambda"))
125+
.handler("index.handler")
126+
.build())
127+
.listenerProps(new BaseApplicationListenerProps.Builder()
128+
.certificates(List.of(listenerCertificate))
129+
.build())
130+
.publicApi(true)
131+
.build());
132+
```
63133

64134
## Pattern Construct Props
65135

source/patterns/@aws-solutions-constructs/aws-apigateway-dynamodb/README.md

+20-9
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,37 @@
2626
## Overview
2727
This AWS Solutions Construct implements an Amazon API Gateway REST API connected to Amazon DynamoDB table.
2828

29-
Here is a minimal deployable pattern definition in Typescript:
29+
Here is a minimal deployable pattern definition in
3030

31+
Typescript:
3132
``` typescript
33+
import { Construct } from 'constructs';
34+
import { Stack, StackProps } from 'aws-cdk-lib';
3235
import { ApiGatewayToDynamoDBProps, ApiGatewayToDynamoDB } from "@aws-solutions-constructs/aws-apigateway-dynamodb";
3336

3437
new ApiGatewayToDynamoDB(this, 'test-api-gateway-dynamodb-default', {});
35-
3638
```
3739

38-
## Initializer
40+
Python
41+
``` python
42+
from aws_solutions_constructs.aws_apigateway_dynamodb import ApiGatewayToDynamoDB
43+
from aws_cdk import Stack
44+
from constructs import Construct
3945

40-
``` text
41-
new ApiGatewayToDynamoDB(scope: Construct, id: string, props: ApiGatewayToDynamoDBProps);
46+
ApiGatewayToDynamoDB(self, 'test-api-gateway-dynamodb-default')
4247
```
4348

44-
_Parameters_
49+
Java
50+
``` java
51+
import software.constructs.Construct;
52+
53+
import software.amazon.awscdk.Stack;
54+
import software.amazon.awscdk.StackProps;
55+
import software.amazon.awsconstructs.services.apigatewaydynamodb.*;
4556

46-
* scope [`Construct`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.Construct.html)
47-
* id `string`
48-
* props [`ApiGatewayToDynamoDBProps`](#pattern-construct-props)
57+
new ApiGatewayToDynamoDB(this, "test-api-gateway-dynamodb-default", new ApiGatewayToDynamoDBProps.Builder()
58+
.build());
59+
```
4960

5061
## Pattern Construct Props
5162

source/patterns/@aws-solutions-constructs/aws-apigateway-iot/README.md

+22-10
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,41 @@ This construct creates a scalable HTTPS proxy between API Gateway and AWS IoT. T
3030

3131
This implementation enables write-only messages to be published on given MQTT topics, and also supports shadow updates of HTTPS devices to allowed things in the device registry. It does not involve Lambda functions for proxying messages, and instead relies on direct API Gateway to AWS IoT integration which supports both JSON messages as well as binary messages.
3232

33-
Here is a minimal deployable pattern definition in Typescript:
33+
Here is a minimal deployable pattern definition:
3434

35+
Typescript
3536
``` typescript
37+
import { Construct } from 'constructs';
38+
import { Stack, StackProps } from 'aws-cdk-lib';
3639
import { ApiGatewayToIot } from '@aws-solutions-constructs/aws-apigateway-iot';
3740

3841
new ApiGatewayToIot(this, 'ApiGatewayToIotPattern', {
3942
iotEndpoint: 'a1234567890123-ats'
4043
});
41-
4244
```
4345

44-
## Initializer
46+
Python
47+
``` python
48+
from aws_solutions_constructs.aws_apigateway_iot import ApiGatewayToIot
49+
from aws_cdk import Stack
50+
from constructs import Construct
4551

46-
``` text
47-
new ApiGatewayToIot(scope: Construct, id: string, props: ApiGatewayToIotProps);
52+
ApiGatewayToIot(self, 'ApiGatewayToIotPattern',
53+
iot_endpoint='a1234567890123-ats'
54+
)
4855
```
56+
Java
57+
``` java
58+
import software.constructs.Construct;
4959

50-
_Parameters_
51-
52-
* scope [`Construct`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.Construct.html)
53-
* id `string`
54-
* props [`ApiGatewayToIotProps`](#pattern-construct-props)
60+
import software.amazon.awscdk.Stack;
61+
import software.amazon.awscdk.StackProps;
62+
import software.amazon.awsconstructs.services.apigatewayiot.*;
5563

64+
new ApiGatewayToIot(this, "ApiGatewayToIotPattern", new ApiGatewayToIotProps.Builder()
65+
.iotEndpoint("a1234567890123-ats")
66+
.build());
67+
```
5668
## Pattern Construct Props
5769

5870
| **Name** | **Type** | **Description** |

0 commit comments

Comments
 (0)