Skip to content

Commit

Permalink
Merge branch 'master' into sfn-athena
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdottv authored Nov 10, 2020
2 parents 22240f7 + 8058b38 commit bf0754f
Show file tree
Hide file tree
Showing 9 changed files with 648 additions and 480 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-appsync/lib/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export interface HttpDataSourceProps extends BaseDataSourceProps {
/**
* An AppSync datasource backed by a http endpoint
*/
export class HttpDataSource extends BaseDataSource {
export class HttpDataSource extends BackedDataSource {
constructor(scope: Construct, id: string, props: HttpDataSourceProps) {
const authorizationConfig = props.authorizationConfig ? {
authorizationType: 'AWS_IAM',
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-appsync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
"cdk-integ-tools": "0.0.0",
"cfn2ts": "0.0.0",
"jest": "^26.6.3",
"pkglint": "0.0.0"
"pkglint": "0.0.0",
"@aws-cdk/aws-stepfunctions": "0.0.0"
},
"dependencies": {
"@aws-cdk/aws-cognito": "0.0.0",
Expand Down
73 changes: 72 additions & 1 deletion packages/@aws-cdk/aws-appsync/test/appsync-http.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import '@aws-cdk/assert/jest';
import * as path from 'path';
import * as sfn from '@aws-cdk/aws-stepfunctions';
import * as cdk from '@aws-cdk/core';
import * as appsync from '../lib';

Expand Down Expand Up @@ -86,13 +87,84 @@ describe('Http Data Source configuration', () => {
});
});

test('other aws resources can grant http data source', () => {
// WHEN
const machineArn = 'arn:aws:states:us-east-1::stateMachine:hello';
const machine = sfn.StateMachine.fromStateMachineArn(stack, 'importedMachine', machineArn);
const ds = api.addHttpDataSource('ds', endpoint, {
name: 'custom',
description: 'custom description',
authorizationConfig: {
signingRegion: 'us-east-1',
signingServiceName: 'states',
},
});
machine.grantRead(ds);


// THEN
expect(stack).toHaveResourceLike('AWS::IAM::Policy', {
PolicyDocument: {
Statement: [
{
Action: [
'states:ListExecutions',
'states:ListStateMachines',
],
Effect: 'Allow',
Resource: machineArn,
},
{
Action: [
'states:DescribeExecution',
'states:DescribeStateMachineForExecution',
'states:GetExecutionHistory',
],
Effect: 'Allow',
Resource: {
'Fn::Join': [
'',
[
'arn:',
{
Ref: 'AWS::Partition',
},
':states:',
{
Ref: 'AWS::Region',
},
':',
{
Ref: 'AWS::AccountId',
},
':execution:hello:*',
],
],
},
},
{
Action: [
'states:ListActivities',
'states:DescribeStateMachine',
'states:DescribeActivity',
],
Effect: 'Allow',
Resource: '*',
},
],
Version: '2012-10-17',
},
});
});

test('appsync errors when creating multiple http data sources with no configuration', () => {
// THEN
expect(() => {
api.addHttpDataSource('ds', endpoint);
api.addHttpDataSource('ds', endpoint);
}).toThrow("There is already a Construct with name 'ds' in GraphqlApi [baseApi]");
});

});

describe('adding http data source from imported api', () => {
Expand Down Expand Up @@ -125,4 +197,3 @@ describe('adding http data source from imported api', () => {
});
});
});

11 changes: 11 additions & 0 deletions packages/@aws-cdk/aws-cloudwatch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,17 @@ dashboard.addWidgets(new GraphWidget({
}));
```

The graph view can be changed from default 'timeSeries' to 'bar' or 'pie'.

```ts
dashboard.addWidgets(new GraphWidget({
// ...
// ...

view: GraphWidgetView.BAR,
}));
```

### Alarm widget

An alarm widget shows the graph and the alarm line of a single alarm:
Expand Down
28 changes: 27 additions & 1 deletion packages/@aws-cdk/aws-cloudwatch/lib/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,24 @@ export class AlarmWidget extends ConcreteWidget {
}
}

/**
* Types of view
*/
export enum GraphWidgetView {
/**
* Display as a line graph.
*/
TIME_SERIES = 'timeSeries',
/**
* Display as a bar graph.
*/
BAR = 'bar',
/**
* Display as a pie graph.
*/
PIE = 'pie',
}

/**
* Properties for a GraphWidget
*/
Expand Down Expand Up @@ -187,6 +205,14 @@ export interface GraphWidgetProps extends MetricWidgetProps {
* @default false
*/
readonly liveData?: boolean;


/**
* Display this metric
*
* @default TimeSeries
*/
readonly view?: GraphWidgetView;
}

/**
Expand Down Expand Up @@ -214,7 +240,7 @@ export class GraphWidget extends ConcreteWidget {
x: this.x,
y: this.y,
properties: {
view: 'timeSeries',
view: this.props.view ?? GraphWidgetView.TIME_SERIES,
title: this.props.title,
region: this.props.region || cdk.Aws.REGION,
stacked: this.props.stacked,
Expand Down
26 changes: 25 additions & 1 deletion packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Stack } from '@aws-cdk/core';
import { Test } from 'nodeunit';
import { Alarm, AlarmWidget, Color, GraphWidget, LegendPosition, LogQueryWidget, Metric, Shading, SingleValueWidget, LogQueryVisualizationType } from '../lib';
import { Alarm, AlarmWidget, Color, GraphWidget, GraphWidgetView, LegendPosition, LogQueryWidget, Metric, Shading, SingleValueWidget, LogQueryVisualizationType } from '../lib';

export = {
'add stacked property to graphs'(test: Test) {
Expand Down Expand Up @@ -86,6 +86,30 @@ export = {
test.done();
},

'bar view'(test: Test) {
// WHEN
const stack = new Stack();
const widget = new GraphWidget({
title: 'Test widget',
view: GraphWidgetView.BAR,
});

// THEN
test.deepEqual(stack.resolve(widget.toJson()), [{
type: 'metric',
width: 6,
height: 6,
properties: {
view: 'bar',
title: 'Test widget',
region: { Ref: 'AWS::Region' },
yAxis: {},
},
}]);

test.done();
},

'singlevalue widget'(test: Test) {
// GIVEN
const stack = new Stack();
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-lambda-nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
"delay": "4.4.0",
"parcel": "2.0.0-nightly.442",
"parcel": "2.0.0-nightly.443",
"pkglint": "0.0.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion tools/cdk-build-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"pkglint": "0.0.0"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^4.6.1",
"@typescript-eslint/eslint-plugin": "^4.7.0",
"@typescript-eslint/parser": "^4.6.1",
"eslint-plugin-cdk": "0.0.0",
"awslint": "0.0.0",
Expand Down
Loading

0 comments on commit bf0754f

Please sign in to comment.