Skip to content
/ aws-cdk Public
forked from aws/aws-cdk

Commit

Permalink
Merge branch 'main' into merge-back/2.43.1
Browse files Browse the repository at this point in the history
  • Loading branch information
iliapolo authored Sep 23, 2022
2 parents c1ebb85 + 89bc626 commit c66a696
Show file tree
Hide file tree
Showing 64 changed files with 3,085 additions and 442 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/github-merit-badger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:

jobs:
call-action:
if: ${{ github.actor != 'dependabot[bot]' }} && ${{ github.actor != 'mergify[bot]' }}
runs-on: ubuntu-latest
permissions:
pull-requests: write
Expand All @@ -17,4 +18,4 @@ jobs:
badges: '[beginning-contributor,repeat-contributor,valued-contributor,admired-contributor,star-contributor,distinguished-contributor]'
thresholds: '[0,3,6,13,25,50]'
badge-type: 'achievement'
ignore-usernames: '[RomainMuller,rix0rrr,Jerry-AWS,MrArnoldPalmer,iliapolo,otaviomacedo,madeline-k,kaizencc,comcalvi,corymhall,peterwoodworth,ryparker,TheRealAmazonKendra,vinayak-kukreja,Naumel,mrgrain,aws-cdk-automation,dependabot,mergify]'
ignore-usernames: '[RomainMuller,rix0rrr,Jerry-AWS,MrArnoldPalmer,iliapolo,otaviomacedo,madeline-k,kaizencc,comcalvi,corymhall,peterwoodworth,ryparker,TheRealAmazonKendra,vinayak-kukreja,Naumel,mrgrain,aws-cdk-automation]'
3 changes: 2 additions & 1 deletion .github/workflows/pr-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

name: PR Linter
on:
pull_request:
# Necessary to have sufficient permissions to write to the PR
pull_request_target:
types:
- labeled
- unlabeled
Expand Down
19 changes: 19 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ let us know if it's not up-to-date (even better, submit a PR with your correcti
- [Debugging](#debugging)
- [Connecting the VS Code Debugger](#connecting-the-vs-code-debugger)
- [Run a CDK unit test in the debugger](#run-a-cdk-unit-test-in-the-debugger)
- [Badges (Pilot Program)](#badges-pilot-program)
- [Related Repositories](#related-repositories)

## Getting Started
Expand Down Expand Up @@ -1116,6 +1117,24 @@ $ node --inspect-brk /path/to/aws-cdk/node_modules/.bin/jest -i -t 'TESTNAME'

3. On the `Run` pane of VSCode, select the run configuration **Attach to NodeJS** and click the button.

## Badges (Pilot Program)

> CDK Merit Badges is a Pilot Program. The badges you get are experimental and may change.
CDK Merit Badges is a program aimed at enhancing the CDK contributor experience. When you
submit new pull requests to the CDK repository, you will receive a merit badge that reflects
how many prior successful contributions you have to the repository. Right now, these badges
are just for fun and are meant as a small incentive to continued contributions to the CDK.

The badges have the following meaning:

- `beginning-contributor`: contributed between 0-2 PRs to the CDK
- `repeat-contributor`: contributed between 3-5 PRs to the CDK
- `valued-contributor`: contributed between 6-12 PRs to the CDK
- `admired-contributor`: contributed between 13-24 PRs to the CDK
- `star-contributor`: contributed between 25-49 PRs to the CDK
- `distinguished-contributor`: contributed 50+ PRs to the CDK

## Related Repositories

* [Samples](https://github.com/aws-samples/aws-cdk-examples): includes sample code in multiple languages
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ export class InterfaceVpcEndpointAwsService implements IInterfaceVpcEndpointServ
public static readonly LAMBDA = new InterfaceVpcEndpointAwsService('lambda');
public static readonly TRANSCRIBE = new InterfaceVpcEndpointAwsService('transcribe');
public static readonly XRAY = new InterfaceVpcEndpointAwsService('xray');
public static readonly SECURITYHUB = new InterfaceVpcEndpointAwsService('securityhub');

/**
* The name of the service. e.g. com.amazonaws.us-east-1.ecs
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-ec2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@
"docs-public-apis:@aws-cdk/aws-ec2.InterfaceVpcEndpointAwsService.LAMBDA",
"docs-public-apis:@aws-cdk/aws-ec2.InterfaceVpcEndpointAwsService.TRANSCRIBE",
"docs-public-apis:@aws-cdk/aws-ec2.InterfaceVpcEndpointAwsService.XRAY",
"docs-public-apis:@aws-cdk/aws-ec2.InterfaceVpcEndpointAwsService.SECURITYHUB",
"docs-public-apis:@aws-cdk/aws-ec2.Port.toString",
"docs-public-apis:@aws-cdk/aws-ec2.PrivateSubnet.fromPrivateSubnetAttributes",
"docs-public-apis:@aws-cdk/aws-ec2.PublicSubnet.fromPublicSubnetAttributes",
Expand Down
17 changes: 17 additions & 0 deletions packages/@aws-cdk/aws-eks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,23 @@ cluster.addHelmChart('test-chart', {
});
```

Nested values passed to the `values` parameter should be provided as a nested dictionary:

```ts
cluster.addHelmChart('ExternalSecretsOperator', {
chart: 'external-secrets',
release: 'external-secrets',
repository: 'https://charts.external-secrets.io',
namespace: 'external-secrets',
values: {
installCRDs: true,
webhook: {
port: 9443
}
},
});
```

### OCI Charts

OCI charts are also supported.
Expand Down
5 changes: 5 additions & 0 deletions packages/@aws-cdk/aws-eks/lib/helm-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ export interface HelmChartOptions {

/**
* The values to be used by the chart.
* For nested values use a nested dictionary. For example:
* values: {
* installationCRDs: true,
* webhook: { port: 9443 }
* }
* @default - No values are provided to the chart.
*/
readonly values?: {[key: string]: any};
Expand Down
16 changes: 15 additions & 1 deletion packages/@aws-cdk/aws-neptune/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const cluster = new neptune.DatabaseCluster(this, 'Database', {
});
```

Additionally it is also possible to add replicas using `DatabaseInstance` for an existing cluster.
Additionally, it is also possible to add replicas using `DatabaseInstance` for an existing cluster.

```ts fixture=with-cluster
const replica1 = new neptune.DatabaseInstance(this, 'Instance', {
Expand All @@ -143,3 +143,17 @@ new neptune.DatabaseCluster(this, 'Cluster', {
autoMinorVersionUpgrade: true,
});
```

## Metrics

Both `DatabaseCluster` and `DatabaseInstance` provide a `metric()` method to help with cluster-level and instance-level monitoring.

```ts
declare const cluster: neptune.DatabaseCluster;
declare const instance: neptune.DatabaseInstance;

cluster.metric('SparqlRequestsPerSec'); // cluster-level SparqlErrors metric
instance.metric('SparqlRequestsPerSec') // instance-level SparqlErrors metric
```

For more details on the available metrics, refer to https://docs.aws.amazon.com/neptune/latest/userguide/cw-metrics.html
20 changes: 20 additions & 0 deletions packages/@aws-cdk/aws-neptune/lib/cluster.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import * as ec2 from '@aws-cdk/aws-ec2';
import * as iam from '@aws-cdk/aws-iam';
import * as kms from '@aws-cdk/aws-kms';
Expand Down Expand Up @@ -284,6 +285,14 @@ export interface IDatabaseCluster extends IResource, ec2.IConnectable {
* Grant the given identity connection access to the database.
*/
grantConnect(grantee: iam.IGrantable): iam.Grant;

/**
* Return the given named metric associated with this DatabaseCluster instance
*
* @see https://docs.aws.amazon.com/neptune/latest/userguide/cw-metrics.html
* @see https://docs.aws.amazon.com/neptune/latest/userguide/cw-dimensions.html
*/
metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric;
}

/**
Expand Down Expand Up @@ -398,6 +407,17 @@ export abstract class DatabaseClusterBase extends Resource implements IDatabaseC
public grantConnect(grantee: iam.IGrantable): iam.Grant {
return this.grant(grantee, 'neptune-db:*');
}

public metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return new cloudwatch.Metric({
namespace: 'AWS/Neptune',
dimensionsMap: {
DBClusterIdentifier: this.clusterIdentifier,
},
metricName,
...props,
});
}
}

/**
Expand Down
60 changes: 53 additions & 7 deletions packages/@aws-cdk/aws-neptune/lib/instance.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import * as ec2 from '@aws-cdk/aws-ec2';
import * as cdk from '@aws-cdk/core';
import { Construct } from 'constructs';
Expand Down Expand Up @@ -165,6 +166,14 @@ export interface IDatabaseInstance extends cdk.IResource {
* @attribute Port
*/
readonly dbInstanceEndpointPort: string;

/**
* Return the given named metric associated with this database instance
*
* @see https://docs.aws.amazon.com/neptune/latest/userguide/cw-metrics.html
* @see https://docs.aws.amazon.com/neptune/latest/userguide/cw-dimensions.html
*/
metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric;
}

/**
Expand Down Expand Up @@ -233,27 +242,64 @@ export interface DatabaseInstanceProps {
}

/**
* A database instance
*
* @resource AWS::Neptune::DBInstance
* A new or imported database instance.
*/
export class DatabaseInstance extends cdk.Resource implements IDatabaseInstance {

export abstract class DatabaseInstanceBase extends cdk.Resource implements IDatabaseInstance {
/**
* Import an existing database instance.
*/
public static fromDatabaseInstanceAttributes(scope: Construct, id: string, attrs: DatabaseInstanceAttributes): IDatabaseInstance {
class Import extends cdk.Resource implements IDatabaseInstance {
class Import extends DatabaseInstanceBase implements IDatabaseInstance {
public readonly defaultPort = ec2.Port.tcp(attrs.port);
public readonly instanceIdentifier = attrs.instanceIdentifier;
public readonly dbInstanceEndpointAddress = attrs.instanceEndpointAddress;
public readonly dbInstanceEndpointPort = attrs.port.toString();
public readonly instanceEndpoint = new Endpoint(attrs.instanceEndpointAddress, attrs.port);
}

return new Import(scope, id);
}

/**
* @inheritdoc
*/
public abstract readonly dbInstanceEndpointAddress: string;

/**
* @inheritdoc
*/
public abstract readonly dbInstanceEndpointPort: string;

/**
* @inheritdoc
*/
public abstract readonly instanceEndpoint: Endpoint;

/**
* @inheritdoc
*/
public abstract readonly instanceIdentifier: string;

/**
* @inheritdoc
*/
public metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return new cloudwatch.Metric({
namespace: 'AWS/Neptune',
dimensionsMap: {
DBInstanceIdentifier: this.instanceIdentifier,
},
metricName,
...props,
});
}
}

/**
* A database instance
*
* @resource AWS::Neptune::DBInstance
*/
export class DatabaseInstance extends DatabaseInstanceBase implements IDatabaseInstance {

/**
* The instance's database cluster
Expand Down
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-neptune/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@
"@types/jest": "^27.5.2"
},
"dependencies": {
"@aws-cdk/aws-cloudwatch": "0.0.0",
"@aws-cdk/aws-ec2": "0.0.0",
"@aws-cdk/aws-iam": "0.0.0",
"@aws-cdk/aws-kms": "0.0.0",
"@aws-cdk/core": "0.0.0",
"constructs": "^10.0.0"
},
"peerDependencies": {
"@aws-cdk/aws-cloudwatch": "0.0.0",
"@aws-cdk/aws-ec2": "0.0.0",
"@aws-cdk/aws-iam": "0.0.0",
"@aws-cdk/aws-kms": "0.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "21.0.0",
"files": {
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
"source": {
"path": "ClusterTestDefaultTestDeployAssert6A1BBA9D.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
}
},
"dockerImages": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"Parameters": {
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
}
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5"
],
{
"Ref": "BootstrapVersion"
}
]
}
]
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "21.0.0",
"files": {
"315715ffe6004c7bd7c9874629785c10fd8f65a20d6995ea8eb20188dfb82b7d": {
"c3aa283b33e47bc3d0cb943f014017d1742247b6577982270570cb6cbf5a778c": {
"source": {
"path": "aws-cdk-neptune-integ.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "315715ffe6004c7bd7c9874629785c10fd8f65a20d6995ea8eb20188dfb82b7d.json",
"objectKey": "c3aa283b33e47bc3d0cb943f014017d1742247b6577982270570cb6cbf5a778c.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,26 @@
],
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"Alarm7103F465": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"ComparisonOperator": "LessThanThreshold",
"EvaluationPeriods": 1,
"Dimensions": [
{
"Name": "DBClusterIdentifier",
"Value": {
"Ref": "DatabaseB269D8BB"
}
}
],
"MetricName": "SparqlRequestsPerSec",
"Namespace": "AWS/Neptune",
"Period": 300,
"Statistic": "Average",
"Threshold": 1
}
}
},
"Parameters": {
Expand Down
Loading

0 comments on commit c66a696

Please sign in to comment.