Skip to content

Commit

Permalink
feat(README.md): add python and java minimal deployment (#582)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mickychetta authored Mar 31, 2022
1 parent 32d5d8c commit 2ecd9dd
Show file tree
Hide file tree
Showing 68 changed files with 3,430 additions and 1,115 deletions.
14 changes: 14 additions & 0 deletions .viperlightignore
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ source/patterns/@aws-solutions-constructs/aws-alb-lambda/README.md:35
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/alb-lambda.test.ts:27
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/alb-lambda.test.ts:680
# These are references to the us-east-1 ELBV2 account (publicly known)
source/patterns/@aws-solutions-constructs/aws-route53-alb/test/integ.deployPrivateApi.expected.json:196
source/patterns/@aws-solutions-constructs/aws-route53-alb/test/integ.deployPrivateApiExistingZone.expected.json:853
source/patterns/@aws-solutions-constructs/aws-route53-alb/test/integ.deployPublicApiNewAlb.expected.json:191
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.privateApiNewResources.expected.json:199
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.publicApiNewResources.expected.json:202
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.twoTargets.expected.json:202
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.privateApiExistingResources.expected.json:1067
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.publicApiExistingResources.expected.json:1067
source/patterns/@aws-solutions-constructs/aws-alb-fargate/test/integ.all-new-two-targets.expected.json:1034
source/patterns/@aws-solutions-constructs/aws-alb-fargate/test/integ.all-new-public-http.expected.json:1007
source/patterns/@aws-solutions-constructs/aws-route53-alb/test/integ.deployPrivateApi.expected.json:242
source/patterns/@aws-solutions-constructs/aws-route53-alb/test/integ.deployPrivateApiExistingZone.expected.json:899
source/patterns/@aws-solutions-constructs/aws-route53-alb/test/integ.deployPublicApiNewAlb.expected.json:237
Expand All @@ -155,3 +165,7 @@ source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.privateApiEx
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.publicApiExistingResources.expected.json:1113
source/patterns/@aws-solutions-constructs/aws-alb-fargate/test/integ.all-new-two-targets.expected.json:1081
source/patterns/@aws-solutions-constructs/aws-alb-fargate/test/integ.all-new-public-http.expected.json:1054
source/patterns/@aws-solutions-constructs/aws-alb-fargate/README.md:78
source/patterns/@aws-solutions-constructs/aws-alb-lambda/README.md:84
source/patterns/@aws-solutions-constructs/aws-route53-alb/README.md:59
source/patterns/@aws-solutions-constructs/aws-wafwebacl-alb/README.md:68
103 changes: 81 additions & 22 deletions source/patterns/@aws-solutions-constructs/aws-alb-fargate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,41 +24,100 @@

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

Here is a minimal deployable pattern definition in Typescript:
Here is a minimal deployable pattern definition:

Typescript
``` typescript
import { AlbToFargate, AlbToFargateProps } from '@aws-solutions-constructs/aws-alb-fargate';

// Obtain a pre-existing certificate from your account
const certificate = acm.Certificate.fromCertificateArn(
scope,
'existing-cert',
"arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012"
);

const props: AlbToFargateProps = {
import { Construct } from 'constructs';
import { Stack, StackProps } from 'aws-cdk-lib';
import { AlbToFargate, AlbToFargateProps } from '@aws-solutions-constructs/aws-alb-fargate';
import * as acm from 'aws-cdk-lib/aws-certificatemanager';

const certificate = acm.Certificate.fromCertificateArn(
this,
'existing-cert',
"arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012"
);

const constructProps: AlbToFargateProps = {
ecrRepositoryArn: "arn:aws:ecr:us-east-1:123456789012:repository/your-ecr-repo",
ecrImageVersion: "latest",
listenerProps: {
certificates: [ certificate ]
certificates: [certificate]
},
publicApi: true
};
};

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

## Initializer
Python
``` python
from aws_solutions_constructs.aws_alb_fargate import AlbToFargate, AlbToFargateProps
from aws_cdk import (
aws_certificatemanager as acm,
aws_elasticloadbalancingv2 as alb,
Stack
)
from constructs import Construct

# Obtain a pre-existing certificate from your account
certificate = acm.Certificate.from_certificate_arn(
self,
'existing-cert',
"arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012"
)

# Note - all alb constructs turn on ELB logging by default, so require that an environment including account
# and region be provided when creating the stack
#
# MyStack(app, 'id', env=cdk.Environment(account='679431688440', region='us-east-1'))
AlbToFargate(self, 'new-construct',
ecr_repository_arn="arn:aws:ecr:us-east-1:123456789012:repository/your-ecr-repo",
ecr_image_version="latest",
listener_props=alb.BaseApplicationListenerProps(
certificates=[certificate],
),
public_api=True)

``` text
new AlbToFargate(scope: Construct, id: string, props: AlbToFargateProps);
```

_Parameters_

* scope [`Construct`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.Construct.html)
* id `string`
* props [`AlbToFargateProps`](#pattern-construct-props)
Java
``` java
import software.constructs.Construct;
import java.util.List;

import software.amazon.awscdk.Stack;
import software.amazon.awscdk.StackProps;
import software.amazon.awscdk.services.elasticloadbalancingv2.*;
import software.amazon.awsconstructs.services.albfargate.*;

// The code that defines your stack goes here
// Obtain a pre-existing certificate from your account
ListenerCertificate listenerCertificate = ListenerCertificate
.fromArn("arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012");

// Note - all alb constructs turn on ELB logging by default, so require that an environment including account
// and region be provided when creating the stack
//
// new MyStack(app, "id", StackProps.builder()
// .env(Environment.builder()
// .account("123456789012")
// .region("us-east-1")
// .build());
new AlbToFargate(this, "AlbToFargatePattern", new AlbToFargateProps.Builder()
.ecrRepositoryArn("arn:aws:ecr:us-east-1:123456789012:repository/your-ecr-repo")
.ecrImageVersion("latest")
.listenerProps(new BaseApplicationListenerProps.Builder()
.certificates(List.of(listenerCertificate))
.build())
.publicApi(true)
.build());
```

## Pattern Construct Props

Expand Down
130 changes: 100 additions & 30 deletions source/patterns/@aws-solutions-constructs/aws-alb-lambda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,112 @@

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

Here is a minimal deployable pattern definition in Typescript:
Here is a minimal deployable pattern definition:

Typescript
``` typescript

// Obtain a pre-existing certificate from your account
const certificate = acm.Certificate.fromCertificateArn(
scope,
'existing-cert',
"arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012"
);
const props: AlbToLambdaProps = {
lambdaFunctionProps: {
code: lambda.Code.fromAsset(`${__dirname}/lambda`),
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.handler'
},
listenerProps: {
certificates: [ certificate ]
},
publicApi: true
};
new AlbToLambda(stack, 'new-construct', props);

import { Construct } from 'constructs';
import { Stack, StackProps } from 'aws-cdk-lib';
import { AlbToLambda, AlbToLambdaProps } from '@aws-solutions-constructs/aws-alb-lambda';
import * as acm from 'aws-cdk-lib/aws-certificatemanager';
import * as lambda from 'aws-cdk-lib/aws-lambda';

// Obtain a pre-existing certificate from your account
const certificate = acm.Certificate.fromCertificateArn(
this,
'existing-cert',
"arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012"
);

const constructProps: AlbToLambdaProps = {
lambdaFunctionProps: {
code: lambda.Code.fromAsset(`lambda`),
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.handler'
},
listenerProps: {
certificates: [certificate]
},
publicApi: true
};

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

## Initializer

``` text
new AlbToLambda(scope: Construct, id: string, props: AlbToLambdaProps);
Python
``` python
from aws_solutions_constructs.aws_alb_lambda import AlbToLambda, AlbToLambdaProps
from aws_cdk import (
aws_certificatemanager as acm,
aws_lambda as _lambda,
aws_elasticloadbalancingv2 as alb,
Stack
)
from constructs import Construct

# Obtain a pre-existing certificate from your account
certificate = acm.Certificate.from_certificate_arn(
self,
'existing-cert',
"arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012"
)

# Note - all alb constructs turn on ELB logging by default, so require that an environment including account
# and region be provided when creating the stack
#
# MyStack(app, 'id', env=cdk.Environment(account='679431688440', region='us-east-1'))
AlbToLambda(self, 'new-construct',
lambda_function_props=_lambda.FunctionProps(
runtime=_lambda.Runtime.PYTHON_3_7,
code=_lambda.Code.from_asset('lambda'),
handler='index.handler',
),
listener_props=alb.BaseApplicationListenerProps(
certificates=[certificate]
),
public_api=True)
```

_Parameters_

* scope [`Construct`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.Construct.html)
* id `string`
* props [`AlbToLambdaProps`](#pattern-construct-props)
Java
``` java
import software.constructs.Construct;
import java.util.List;

import software.amazon.awscdk.Stack;
import software.amazon.awscdk.StackProps;
import software.amazon.awscdk.services.elasticloadbalancingv2.*;
import software.amazon.awscdk.services.lambda.*;
import software.amazon.awscdk.services.lambda.Runtime;
import software.amazon.awsconstructs.services.alblambda.*;

// Obtain a pre-existing certificate from your account
ListenerCertificate listenerCertificate = ListenerCertificate
.fromArn("arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012");

// Note - all alb constructs turn on ELB logging by default, so require that an environment including account
// and region be provided when creating the stack
//
// new MyStack(app, "id", StackProps.builder()
// .env(Environment.builder()
// .account("123456789012")
// .region("us-east-1")
// .build());
new AlbToLambda(this, "AlbToLambdaPattern", new AlbToLambdaProps.Builder()
.lambdaFunctionProps(new FunctionProps.Builder()
.runtime(Runtime.NODEJS_14_X)
.code(Code.fromAsset("lambda"))
.handler("index.handler")
.build())
.listenerProps(new BaseApplicationListenerProps.Builder()
.certificates(List.of(listenerCertificate))
.build())
.publicApi(true)
.build());
```

## Pattern Construct Props

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,37 @@
## Overview
This AWS Solutions Construct implements an Amazon API Gateway REST API connected to Amazon DynamoDB table.

Here is a minimal deployable pattern definition in Typescript:
Here is a minimal deployable pattern definition in

Typescript:
``` typescript
import { Construct } from 'constructs';
import { Stack, StackProps } from 'aws-cdk-lib';
import { ApiGatewayToDynamoDBProps, ApiGatewayToDynamoDB } from "@aws-solutions-constructs/aws-apigateway-dynamodb";

new ApiGatewayToDynamoDB(this, 'test-api-gateway-dynamodb-default', {});

```

## Initializer
Python
``` python
from aws_solutions_constructs.aws_apigateway_dynamodb import ApiGatewayToDynamoDB
from aws_cdk import Stack
from constructs import Construct

``` text
new ApiGatewayToDynamoDB(scope: Construct, id: string, props: ApiGatewayToDynamoDBProps);
ApiGatewayToDynamoDB(self, 'test-api-gateway-dynamodb-default')
```

_Parameters_
Java
``` java
import software.constructs.Construct;

import software.amazon.awscdk.Stack;
import software.amazon.awscdk.StackProps;
import software.amazon.awsconstructs.services.apigatewaydynamodb.*;

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

## Pattern Construct Props

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,41 @@ This construct creates a scalable HTTPS proxy between API Gateway and AWS IoT. T

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.

Here is a minimal deployable pattern definition in Typescript:
Here is a minimal deployable pattern definition:

Typescript
``` typescript
import { Construct } from 'constructs';
import { Stack, StackProps } from 'aws-cdk-lib';
import { ApiGatewayToIot } from '@aws-solutions-constructs/aws-apigateway-iot';

new ApiGatewayToIot(this, 'ApiGatewayToIotPattern', {
iotEndpoint: 'a1234567890123-ats'
});

```

## Initializer
Python
``` python
from aws_solutions_constructs.aws_apigateway_iot import ApiGatewayToIot
from aws_cdk import Stack
from constructs import Construct

``` text
new ApiGatewayToIot(scope: Construct, id: string, props: ApiGatewayToIotProps);
ApiGatewayToIot(self, 'ApiGatewayToIotPattern',
iot_endpoint='a1234567890123-ats'
)
```
Java
``` java
import software.constructs.Construct;

_Parameters_

* scope [`Construct`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.Construct.html)
* id `string`
* props [`ApiGatewayToIotProps`](#pattern-construct-props)
import software.amazon.awscdk.Stack;
import software.amazon.awscdk.StackProps;
import software.amazon.awsconstructs.services.apigatewayiot.*;

new ApiGatewayToIot(this, "ApiGatewayToIotPattern", new ApiGatewayToIotProps.Builder()
.iotEndpoint("a1234567890123-ats")
.build());
```
## Pattern Construct Props

| **Name** | **Type** | **Description** |
Expand Down
Loading

0 comments on commit 2ecd9dd

Please sign in to comment.