Skip to content

Commit

Permalink
Merge branch 'master' into feat/init-jest-environment
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored May 13, 2021
2 parents 04f8396 + 282d242 commit 3830216
Show file tree
Hide file tree
Showing 99 changed files with 5,314 additions and 190 deletions.
2 changes: 1 addition & 1 deletion .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pull_request_rules:
label:
add: [ contribution/core ]
conditions:
- author~=^(eladb|RomainMuller|garnaat|nija-at|skinny85|rix0rrr|NGL321|Jerry-AWS|MrArnoldPalmer|NetaNir|iliapolo|njlynch|ericzbeard|ccfife|fulghum|pkandasamy91|SoManyHs|uttarasridhar)$
- author~=^(eladb|RomainMuller|garnaat|nija-at|skinny85|rix0rrr|NGL321|Jerry-AWS|MrArnoldPalmer|NetaNir|iliapolo|njlynch|ericzbeard|ccfife|fulghum|pkandasamy91|SoManyHs|uttarasridhar|otaviomacedo|BenChaimberg|madeline-k)$
- -label~="contribution/core"
- name: automatic merge
actions:
Expand Down
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ The following tools need to be installed on your system prior to installing the
- [Yarn >= 1.19.1, < 2](https://yarnpkg.com/lang/en/docs/install)
- [.NET Core SDK 3.1.x](https://www.microsoft.com/net/download)
- [Python >= 3.6.5, < 4.0](https://www.python.org/downloads/release/python-365/)
- [Docker >= 19.03](https://docs.docker.com/get-docker/)
- the Docker daemon must also be running

First fork the repository, and then run the following commands to clone the repository locally.

Expand Down Expand Up @@ -113,8 +115,9 @@ However, if you wish to build the the entire repository, the following command w

```console
cd <root of the CDK repo>
yarn build
scripts/foreach.sh yarn build
```
Note: The `foreach` command is resumable by default; you must supply `-r` or `--reset` to start a new session.

You are now ready to start contributing to the CDK. See the [Pull Requests](#pull-requests) section on how to make your
changes and submit it as a pull request.
Expand Down
20 changes: 10 additions & 10 deletions packages/@aws-cdk-containers/ecs-service-extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ const nameService = new Service(stack, 'name', {
## Creating an `Environment`

An `Environment` is a place to deploy your services. You can have multiple environments
on a single AWS account. For example you could create a `test` environment as well
as a `production` environment so you have a place to verify that you application
on a single AWS account. For example, you could create a `test` environment as well
as a `production` environment so you have a place to verify that your application
works as intended before you deploy it to a live environment.

Each environment is isolated from other environments. In specific
by default when you create an environment the construct supplies its own VPC,
Each environment is isolated from other environments. In other words,
when you create an environment, by default the construct supplies its own VPC,
ECS Cluster, and any other required resources for the environment:

```ts
const environment = new Environment(stack, 'production');
```

However, you can also choose to build an environment out of a pre-existing VPC,
However, you can also choose to build an environment out of a pre-existing VPC
or ECS Cluster:

```ts
Expand All @@ -89,7 +89,7 @@ const environment = new Environment(stack, 'production', {
## Defining your `ServiceDescription`

The `ServiceDescription` defines what application you want the service to run and
what optional extensions you want to add to the service. The most basic form of a `ServiceExtension` looks like this:
what optional extensions you want to add to the service. The most basic form of a `ServiceDescription` looks like this:

```ts
const nameDescription = new ServiceDescription();
Expand All @@ -105,9 +105,9 @@ nameDescription.add(new Container({
```

Every `ServiceDescription` requires at minimum that you add a `Container` extension
which defines the main application container to run for the service.
which defines the main application (essential) container to run for the service.

After that you can optionally enable additional features for the service using the `ServiceDescription.add()` method:
After that, you can optionally enable additional features for the service using the `ServiceDescription.add()` method:

```ts
nameDescription.add(new AppMeshExtension({ mesh }));
Expand Down Expand Up @@ -238,7 +238,7 @@ frontend.connectTo(backend);

The address that a service will use to talk to another service depends on the
type of ingress that has been created by the extension that did the connecting.
For example if an App Mesh extension has been used then the service is accessible
For example, if an App Mesh extension has been used, then the service is accessible
at a DNS address of `<service name>.<environment name>`. For example:

```ts
Expand Down Expand Up @@ -280,7 +280,7 @@ const backend = new Service(stack, 'backend', {
frontend.connectTo(backend);
```

The above code uses the well known service discovery name for each
The above code uses the well-known service discovery name for each
service, and passes it as an environment variable to the container so
that the container knows what address to use when communicating to
the other service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@
"Ref": "HttpProxyPrivateApiA55E154D"
},
"RouteKey": "$default",
"AuthorizationType": "NONE",
"Target": {
"Fn::Join": [
"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"Ref": "LambdaProxyApi67594471"
},
"RouteKey": "$default",
"AuthorizationType": "NONE",
"Target": {
"Fn::Join": [
"",
Expand Down Expand Up @@ -185,6 +186,7 @@
"Ref": "HttpProxyApiD0217C67"
},
"RouteKey": "$default",
"AuthorizationType": "NONE",
"Target": {
"Fn::Join": [
"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"Ref": "LambdaProxyApi67594471"
},
"RouteKey": "$default",
"AuthorizationType": "NONE",
"Target": {
"Fn::Join": [
"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@
"Ref": "HttpProxyPrivateApiA55E154D"
},
"RouteKey": "$default",
"AuthorizationType": "NONE",
"Target": {
"Fn::Join": [
"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@
"Ref": "HttpProxyPrivateApiA55E154D"
},
"RouteKey": "$default",
"AuthorizationType": "NONE",
"Target": {
"Fn::Join": [
"",
Expand Down
4 changes: 1 addition & 3 deletions packages/@aws-cdk/aws-apigatewayv2/lib/http/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ export class HttpRoute extends Resource implements IHttpRoute {
]));
}

const authorizationType = authBindResult?.authorizationType === HttpAuthorizerType.NONE ? undefined : authBindResult?.authorizationType;

if (authorizationScopes?.length === 0) {
authorizationScopes = undefined;
}
Expand All @@ -167,7 +165,7 @@ export class HttpRoute extends Resource implements IHttpRoute {
routeKey: props.routeKey.key,
target: `integrations/${integration.integrationId}`,
authorizerId: authBindResult?.authorizerId,
authorizationType,
authorizationType: authBindResult?.authorizationType ?? HttpAuthorizerType.NONE, // must be explicitly NONE (not undefined) for stack updates to work correctly
authorizationScopes,
};

Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-apigatewayv2/test/http/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ describe('HttpApi', () => {

expect(stack).toHaveResource('AWS::ApiGatewayV2::Route', {
RouteKey: 'GET /chickens',
AuthorizationType: 'NONE',
AuthorizerId: ABSENT,
});
});
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-apigatewayv2/test/http/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('HttpRoute', () => {
],
],
},
AuthorizationType: 'NONE',
});

expect(stack).toHaveResource('AWS::ApiGatewayV2::Integration', {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-appmesh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ App Mesh gives you consistent visibility and network traffic controls for every

App Mesh supports microservice applications that use service discovery naming for their components. To use App Mesh, you must have an existing application running on AWS Fargate, Amazon ECS, Amazon EKS, Kubernetes on AWS, or Amazon EC2.

For futher information on **AWS AppMesh** visit the [AWS Docs for AppMesh](https://docs.aws.amazon.com/app-mesh/index.html).
For further information on **AWS AppMesh** visit the [AWS Docs for AppMesh](https://docs.aws.amazon.com/app-mesh/index.html).

## Create the App and Stack

Expand Down
47 changes: 44 additions & 3 deletions packages/@aws-cdk/aws-appsync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,47 @@ httpDs.createResolver({
});
```

### Elasticsearch

AppSync has builtin support for Elasticsearch from domains that are provisioned
through your AWS account. You can use AppSync resolvers to perform GraphQL operations
such as queries, mutations, and subscriptions.

```ts
const user = new User(stack, 'User');
const domain = new es.Domain(stack, 'Domain', {
version: es.ElasticsearchVersion.V7_1,
removalPolicy: cdk.RemovalPolicy.DESTROY,
fineGrainedAccessControl: { masterUserArn: user.userArn },
encryptionAtRest: { enabled: true },
nodeToNodeEncryption: true,
enforceHttps: true,
});

const ds = api.addElasticsearchDataSource('ds', domain);

ds.createResolver({
typeName: 'Query',
fieldName: 'getTests',
requestMappingTemplate: appsync.MappingTemplate.fromString(JSON.stringify({
version: '2017-02-28',
operation: 'GET',
path: '/id/post/_search',
params: {
headers: {},
queryString: {},
body: { from: 0, size: 50 },
},
})),
responseMappingTemplate: appsync.MappingTemplate.fromString(`[
#foreach($entry in $context.result.hits.hits)
#if( $velocityCount > 1 ) , #end
$utils.toJson($entry.get("_source"))
#end
]`),
});
```

## Schema

Every GraphQL Api needs a schema to define the Api. CDK offers `appsync.Schema`
Expand Down Expand Up @@ -718,7 +759,7 @@ You can create Object Types in three ways:
name: 'demo',
});
const demo = new appsync.ObjectType('Demo', {
defintion: {
definition: {
id: appsync.GraphqlType.string({ isRequired: true }),
version: appsync.GraphqlType.string({ isRequired: true }),
},
Expand All @@ -741,7 +782,7 @@ You can create Object Types in three ways:
```ts
import { required_string } from './scalar-types';
export const demo = new appsync.ObjectType('Demo', {
defintion: {
definition: {
id: required_string,
version: required_string,
},
Expand All @@ -765,7 +806,7 @@ You can create Object Types in three ways:
});
const demo = new appsync.ObjectType('Demo', {
interfaceTypes: [ node ],
defintion: {
definition: {
version: appsync.GraphqlType.string({ isRequired: true }),
},
});
Expand Down
28 changes: 28 additions & 0 deletions packages/@aws-cdk/aws-appsync/lib/data-source.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ITable } from '@aws-cdk/aws-dynamodb';
import { IDomain } from '@aws-cdk/aws-elasticsearch';
import { Grant, IGrantable, IPrincipal, IRole, Role, ServicePrincipal } from '@aws-cdk/aws-iam';
import { IFunction } from '@aws-cdk/aws-lambda';
import { IServerlessCluster } from '@aws-cdk/aws-rds';
Expand Down Expand Up @@ -363,4 +364,31 @@ export class RdsDataSource extends BackedDataSource {
scope: this,
});
}
}

/**
* Properities for the Elasticsearch Data Source
*/
export interface ElasticsearchDataSourceProps extends BackedDataSourceProps {
/**
* The elasticsearch domain containing the endpoint for the data source
*/
readonly domain: IDomain;
}

/**
* An Appsync datasource backed by Elasticsearch
*/
export class ElasticsearchDataSource extends BackedDataSource {
constructor(scope: Construct, id: string, props: ElasticsearchDataSourceProps) {
super(scope, id, props, {
type: 'AMAZON_ELASTICSEARCH',
elasticsearchConfig: {
awsRegion: props.domain.stack.region,
endpoint: `https://${props.domain.domainEndpoint}`,
},
});

props.domain.grantReadWrite(this);
}
}
28 changes: 27 additions & 1 deletion packages/@aws-cdk/aws-appsync/lib/graphqlapi-base.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ITable } from '@aws-cdk/aws-dynamodb';
import { IDomain } from '@aws-cdk/aws-elasticsearch';
import { IFunction } from '@aws-cdk/aws-lambda';
import { IServerlessCluster } from '@aws-cdk/aws-rds';
import { ISecret } from '@aws-cdk/aws-secretsmanager';
import { CfnResource, IResource, Resource } from '@aws-cdk/core';
import { DynamoDbDataSource, HttpDataSource, LambdaDataSource, NoneDataSource, RdsDataSource, AwsIamConfig } from './data-source';
import { DynamoDbDataSource, HttpDataSource, LambdaDataSource, NoneDataSource, RdsDataSource, AwsIamConfig, ElasticsearchDataSource } from './data-source';
import { Resolver, ExtendedResolverProps } from './resolver';

/**
Expand Down Expand Up @@ -110,6 +111,15 @@ export interface IGraphqlApi extends IResource {
options?: DataSourceOptions
): RdsDataSource;

/**
* add a new elasticsearch data source to this API
*
* @param id The data source's id
* @param domain The elasticsearch domain for this data source
* @param options The optional configuration for this data source
*/
addElasticsearchDataSource(id: string, domain: IDomain, options?: DataSourceOptions): ElasticsearchDataSource;

/**
* creates a new resolver for this datasource and API using the given properties
*/
Expand Down Expand Up @@ -228,6 +238,22 @@ export abstract class GraphqlApiBase extends Resource implements IGraphqlApi {
});
}

/**
* add a new elasticsearch data source to this API
*
* @param id The data source's id
* @param domain The elasticsearch domain for this data source
* @param options The optional configuration for this data source
*/
public addElasticsearchDataSource(id: string, domain: IDomain, options?: DataSourceOptions): ElasticsearchDataSource {
return new ElasticsearchDataSource(this, id, {
api: this,
name: options?.name,
description: options?.description,
domain,
});
}

/**
* creates a new resolver for this datasource and API using the given properties
*/
Expand Down
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-appsync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"@aws-cdk/aws-cognito": "0.0.0",
"@aws-cdk/aws-dynamodb": "0.0.0",
"@aws-cdk/aws-ec2": "0.0.0",
"@aws-cdk/aws-elasticsearch": "0.0.0",
"@aws-cdk/aws-rds": "0.0.0",
"@aws-cdk/aws-iam": "0.0.0",
"@aws-cdk/aws-secretsmanager": "0.0.0",
Expand All @@ -97,6 +98,7 @@
"@aws-cdk/aws-cognito": "0.0.0",
"@aws-cdk/aws-dynamodb": "0.0.0",
"@aws-cdk/aws-ec2": "0.0.0",
"@aws-cdk/aws-elasticsearch": "0.0.0",
"@aws-cdk/aws-iam": "0.0.0",
"@aws-cdk/aws-lambda": "0.0.0",
"@aws-cdk/aws-s3-assets": "0.0.0",
Expand Down
Loading

0 comments on commit 3830216

Please sign in to comment.