Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change @aws-cdk/cdk to @aws-cdk/core #62

Merged
merged 22 commits into from
Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Create a directory with a name that is descriptive of the resource type or workf
},
"dependencies": {
...
"@aws-cdk/cdk": "^0.23.0"
"@aws-cdk/core": "^0.36.0"
}
}
```
Expand Down
16 changes: 8 additions & 8 deletions typescript/api-cors-lambda-crud-dynamodb/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import apigateway = require('@aws-cdk/aws-apigateway');
import dynamodb = require('@aws-cdk/aws-dynamodb');
import lambda = require('@aws-cdk/aws-lambda');
import cdk = require('@aws-cdk/cdk');
import cdk = require('@aws-cdk/core');

export class ApiLambdaCrudDynamoDBStack extends cdk.Stack {
constructor(app: cdk.App, id: string) {
Expand All @@ -10,15 +10,15 @@ export class ApiLambdaCrudDynamoDBStack extends cdk.Stack {
const dynamoTable = new dynamodb.Table(this, 'items', {
partitionKey: {
name: 'itemId',
type: dynamodb.AttributeType.String
type: dynamodb.AttributeType.STRING
},
tableName: 'items'
});

const getOneLambda = new lambda.Function(this, 'getOneItemFunction', {
code: new lambda.AssetCode('src'),
handler: 'get-one.handler',
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.NODEJS_8_10,
environment: {
TABLE_NAME: dynamoTable.tableName,
PRIMARY_KEY: 'itemId'
Expand All @@ -28,7 +28,7 @@ export class ApiLambdaCrudDynamoDBStack extends cdk.Stack {
const getAllLambda = new lambda.Function(this, 'getAllItemsFunction', {
code: new lambda.AssetCode('src'),
handler: 'get-all.handler',
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.NODEJS_8_10,
environment: {
TABLE_NAME: dynamoTable.tableName,
PRIMARY_KEY: 'itemId'
Expand All @@ -38,7 +38,7 @@ export class ApiLambdaCrudDynamoDBStack extends cdk.Stack {
const createOne = new lambda.Function(this, 'createItemFunction', {
code: new lambda.AssetCode('src'),
handler: 'create.handler',
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.NODEJS_8_10,
environment: {
TABLE_NAME: dynamoTable.tableName,
PRIMARY_KEY: 'itemId'
Expand All @@ -48,7 +48,7 @@ export class ApiLambdaCrudDynamoDBStack extends cdk.Stack {
const updateOne = new lambda.Function(this, 'updateItemFunction', {
code: new lambda.AssetCode('src'),
handler: 'update-one.handler',
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.NODEJS_8_10,
environment: {
TABLE_NAME: dynamoTable.tableName,
PRIMARY_KEY: 'itemId'
Expand All @@ -58,7 +58,7 @@ export class ApiLambdaCrudDynamoDBStack extends cdk.Stack {
const deleteOne = new lambda.Function(this, 'deleteItemFunction', {
code: new lambda.AssetCode('src'),
handler: 'delete-one.handler',
runtime: lambda.Runtime.NodeJS810,
runtime: lambda.Runtime.NODEJS_8_10,
environment: {
TABLE_NAME: dynamoTable.tableName,
PRIMARY_KEY: 'itemId'
Expand Down Expand Up @@ -108,7 +108,7 @@ export function addCorsOptions(apiResource: apigateway.IResource) {
'method.response.header.Access-Control-Allow-Methods': "'OPTIONS,GET,PUT,POST,DELETE'",
},
}],
passthroughBehavior: apigateway.PassthroughBehavior.Never,
passthroughBehavior: apigateway.PassthroughBehavior.NEVER,
requestTemplates: {
"application/json": "{\"statusCode\": 200}"
},
Expand Down
2 changes: 1 addition & 1 deletion typescript/api-cors-lambda-crud-dynamodb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"@aws-cdk/aws-apigateway": "*",
"@aws-cdk/aws-dynamodb": "*",
"@aws-cdk/aws-lambda": "*",
"@aws-cdk/cdk": "*"
"@aws-cdk/core": "*"
}
}
4 changes: 2 additions & 2 deletions typescript/application-load-balancer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import autoscaling = require('@aws-cdk/aws-autoscaling');
import ec2 = require('@aws-cdk/aws-ec2');
import elbv2 = require('@aws-cdk/aws-elasticloadbalancingv2');
import cdk = require('@aws-cdk/cdk');
import cdk = require('@aws-cdk/core');

class LoadBalancerStack extends cdk.Stack {
constructor(app: cdk.App, id: string) {
Expand All @@ -12,7 +12,7 @@ class LoadBalancerStack extends cdk.Stack {

const asg = new autoscaling.AutoScalingGroup(this, 'ASG', {
vpc,
instanceType: new ec2.InstanceTypePair(ec2.InstanceClass.Burstable2, ec2.InstanceSize.Micro),
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.MICRO),
machineImage: new ec2.AmazonLinuxImage(),
});

Expand Down
2 changes: 1 addition & 1 deletion typescript/application-load-balancer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"@aws-cdk/aws-autoscaling": "*",
"@aws-cdk/aws-ec2": "*",
"@aws-cdk/aws-elasticloadbalancingv2": "*",
"@aws-cdk/cdk": "*"
"@aws-cdk/core": "*"
}
}
34 changes: 17 additions & 17 deletions typescript/appsync-graphql-dynamodb/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cdk = require('@aws-cdk/cdk');
import cdk = require('@aws-cdk/core');
import { CfnGraphQLApi, CfnApiKey, CfnGraphQLSchema, CfnDataSource, CfnResolver } from '@aws-cdk/aws-appsync';
import { Table, AttributeType, StreamViewType, BillingMode } from '@aws-cdk/aws-dynamodb';
import { Role, ServicePrincipal } from '@aws-cdk/aws-iam';
import { Role, ServicePrincipal, ManagedPolicy } from '@aws-cdk/aws-iam';


export class AppSyncCdkStack extends cdk.Stack {
Expand All @@ -17,11 +17,11 @@ export class AppSyncCdkStack extends cdk.Stack {
});

new CfnApiKey(this, 'ItemsApiKey', {
apiId: itemsGraphQLApi.graphQlApiApiId
apiId: itemsGraphQLApi.attrApiId
});

const apiSchema = new CfnGraphQLSchema(this, 'ItemsSchema', {
apiId: itemsGraphQLApi.graphQlApiApiId,
apiId: itemsGraphQLApi.attrApiId,
definition: `type ${tableName} {
${tableName}Id: ID!
name: String
Expand All @@ -48,20 +48,20 @@ export class AppSyncCdkStack extends cdk.Stack {
tableName: tableName,
partitionKey: {
name: `${tableName}Id`,
type: AttributeType.String
type: AttributeType.STRING
},
billingMode: BillingMode.PayPerRequest,
streamSpecification: StreamViewType.NewImage
billingMode: BillingMode.PAY_PER_REQUEST,
stream: StreamViewType.NEW_IMAGE
});

const itemsTableRole = new Role(this, 'ItemsDynamoDBRole', {
assumedBy: new ServicePrincipal('appsync.amazonaws.com')
});

itemsTableRole.attachManagedPolicy('arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess');
itemsTableRole.addManagedPolicy(ManagedPolicy.fromAwsManagedPolicyName('arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess'));

const dataSource = new CfnDataSource(this, 'ItemsDataSource', {
apiId: itemsGraphQLApi.graphQlApiApiId,
apiId: itemsGraphQLApi.attrApiId,
name: 'ItemsDynamoDataSource',
type: 'AMAZON_DYNAMODB',
dynamoDbConfig: {
Expand All @@ -72,10 +72,10 @@ export class AppSyncCdkStack extends cdk.Stack {
});

const getOneResolver = new CfnResolver(this, 'GetOneQueryResolver', {
apiId: itemsGraphQLApi.graphQlApiApiId,
apiId: itemsGraphQLApi.attrApiId,
typeName: 'Query',
fieldName: 'getOne',
dataSourceName: dataSource.dataSourceName,
dataSourceName: dataSource.name,
requestMappingTemplate: `{
"version": "2017-02-28",
"operation": "GetItem",
Expand All @@ -88,10 +88,10 @@ export class AppSyncCdkStack extends cdk.Stack {
getOneResolver.addDependsOn(apiSchema);

const getAllResolver = new CfnResolver(this, 'GetAllQueryResolver', {
apiId: itemsGraphQLApi.graphQlApiApiId,
apiId: itemsGraphQLApi.attrApiId,
typeName: 'Query',
fieldName: 'all',
dataSourceName: dataSource.dataSourceName,
dataSourceName: dataSource.name,
requestMappingTemplate: `{
"version": "2017-02-28",
"operation": "Scan",
Expand All @@ -103,10 +103,10 @@ export class AppSyncCdkStack extends cdk.Stack {
getAllResolver.addDependsOn(apiSchema);

const saveResolver = new CfnResolver(this, 'SaveMutationResolver', {
apiId: itemsGraphQLApi.graphQlApiApiId,
apiId: itemsGraphQLApi.attrApiId,
typeName: 'Mutation',
fieldName: 'save',
dataSourceName: dataSource.dataSourceName,
dataSourceName: dataSource.name,
requestMappingTemplate: `{
"version": "2017-02-28",
"operation": "PutItem",
Expand All @@ -122,10 +122,10 @@ export class AppSyncCdkStack extends cdk.Stack {
saveResolver.addDependsOn(apiSchema);

const deleteResolver = new CfnResolver(this, 'DeleteMutationResolver', {
apiId: itemsGraphQLApi.graphQlApiApiId,
apiId: itemsGraphQLApi.attrApiId,
typeName: 'Mutation',
fieldName: 'delete',
dataSourceName: dataSource.dataSourceName,
dataSourceName: dataSource.name,
requestMappingTemplate: `{
"version": "2017-02-28",
"operation": "DeleteItem",
Expand Down
2 changes: 1 addition & 1 deletion typescript/appsync-graphql-dynamodb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"@aws-cdk/aws-appsync": "*",
"@aws-cdk/aws-dynamodb": "*",
"@aws-cdk/aws-iam": "*",
"@aws-cdk/cdk": "*"
"@aws-cdk/core": "*"
}
}
4 changes: 2 additions & 2 deletions typescript/classic-load-balancer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import autoscaling = require('@aws-cdk/aws-autoscaling');
import ec2 = require('@aws-cdk/aws-ec2');
import elb = require('@aws-cdk/aws-elasticloadbalancing');
import cdk = require('@aws-cdk/cdk');
import cdk = require('@aws-cdk/core');

class LoadBalancerStack extends cdk.Stack {
constructor(app: cdk.App, id: string) {
Expand All @@ -12,7 +12,7 @@ class LoadBalancerStack extends cdk.Stack {

const asg = new autoscaling.AutoScalingGroup(this, 'ASG', {
vpc,
instanceType: new ec2.InstanceTypePair(ec2.InstanceClass.Burstable2, ec2.InstanceSize.Micro),
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.MICRO),
machineImage: new ec2.AmazonLinuxImage(),
});

Expand Down
2 changes: 1 addition & 1 deletion typescript/classic-load-balancer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"@aws-cdk/aws-autoscaling": "*",
"@aws-cdk/aws-ec2": "*",
"@aws-cdk/aws-elasticloadbalancing": "*",
"@aws-cdk/cdk": "*"
"@aws-cdk/core": "*"
}
}
2 changes: 1 addition & 1 deletion typescript/custom-resource/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cdk = require('@aws-cdk/cdk');
import cdk = require('@aws-cdk/core');
import { MyCustomResource } from './my-custom-resource';

/**
Expand Down
6 changes: 3 additions & 3 deletions typescript/custom-resource/my-custom-resource.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cfn = require('@aws-cdk/aws-cloudformation');
import lambda = require('@aws-cdk/aws-lambda');
import cdk = require('@aws-cdk/cdk');
import cdk = require('@aws-cdk/core');

import fs = require('fs');

Expand All @@ -22,8 +22,8 @@ export class MyCustomResource extends cdk.Construct {
uuid: 'f7d4f730-4ee1-11e8-9c2d-fa7ae01bbebc',
code: new lambda.InlineCode(fs.readFileSync('custom-resource-handler.py', { encoding: 'utf-8' })),
handler: 'index.main',
timeout: 300,
tbadlov marked this conversation as resolved.
Show resolved Hide resolved
runtime: lambda.Runtime.Python27,
timeout: cdk.Duration.seconds(300),
runtime: lambda.Runtime.PYTHON_2_7,
})),
properties: props
});
Expand Down
2 changes: 1 addition & 1 deletion typescript/custom-resource/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"dependencies": {
"@aws-cdk/aws-cloudformation": "*",
"@aws-cdk/aws-lambda": "*",
"@aws-cdk/cdk": "*"
"@aws-cdk/core": "*"
}
}
16 changes: 10 additions & 6 deletions typescript/ecs/cluster/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import autoscaling = require('@aws-cdk/aws-autoscaling');
import ec2 = require('@aws-cdk/aws-ec2');
import { InstanceType } from '@aws-cdk/aws-ec2';
import ecs = require('@aws-cdk/aws-ecs');
import cdk = require('@aws-cdk/core');

Expand All @@ -11,20 +10,25 @@ class ECSCluster extends cdk.Stack {
const vpc = new ec2.Vpc(this, 'MyVpc', { maxAZs: 2 });

const asg = new autoscaling.AutoScalingGroup(this, 'MyFleet', {
instanceType: new InstanceType("t2.xlarge"),
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.XLARGE),
machineImage: new ecs.EcsOptimizedAmi(),
updateType: autoscaling.UpdateType.REPLACING_UPDATE,
desiredCapacity: 3,
vpc
vpc,
});

const cluster = new ecs.Cluster(this, 'EcsCluster', { vpc });
cluster.addAutoScalingGroup(asg);

cluster.addCapacity('DefaultAutoScalingGroup', {
tbadlov marked this conversation as resolved.
Show resolved Hide resolved
instanceType: new ec2.InstanceType('t2.micro')
});
/**
* This lines seem to break the synth with the following error:
* Error: There is already a Construct with name 'SsmParameterValue:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter' in ECSCluster [MyFirstEcsCluster]
* This will be investigated and code will be left for now. This will break build however.
*/

cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.MICRO)
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion typescript/ecs/ecs-load-balanced-service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BonjourECS extends cdk.Stack {
const vpc = new ec2.Vpc(this, 'MyVpc', { maxAZs: 2 });
const cluster = new ecs.Cluster(this, 'Ec2Cluster', { vpc });
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro')
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.MICRO)
});

// Instantiate ECS Service with just cluster and image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const vpc = new ec2.Vpc(stack, 'Vpc', { maxAZs: 2 });

const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro')
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.MICRO)
});

// Create Task Definition
Expand Down
3 changes: 2 additions & 1 deletion typescript/ecs/ecs-service-with-logging/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ class WillkommenECS extends cdk.Stack {
super(scope, id, props);

const vpc = new ec2.Vpc(this, 'MyVpc', { maxAZs: 2 });

const cluster = new ecs.Cluster(this, 'Ec2Cluster', { vpc });
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro')
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.MICRO)
});

// create a task definition with CloudWatch Logs
Expand Down
2 changes: 1 addition & 1 deletion typescript/ecs/ecs-service-with-task-networking/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const vpc = new ec2.Vpc(stack, 'Vpc', { maxAZs: 2 });

const cluster = new ecs.Cluster(stack, 'awsvpc-ecs-demo-cluster', { vpc });
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro')
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.MICRO)
});

// Create a task definition with its own elastic network interface
Expand Down
10 changes: 5 additions & 5 deletions typescript/ecs/ecs-service-with-task-placement/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ const vpc = new ec2.Vpc(stack, 'Vpc', { maxAZs: 2 });

const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro')
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.MICRO)
});

// Create Task Definition with placement constraint
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TaskDef', {
placementConstraints: [ ecs.PlacementConstraint.distinctInstances() ]
placementConstraints: [ecs.PlacementConstraint.distinctInstances()],
});

const container = taskDefinition.addContainer('web', {
image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
memoryLimitMiB: 256,
});

container.addPortMappings({
containerPort: 80,
hostPort: 8080,
protocol: ecs.Protocol.TCP
protocol: ecs.Protocol.TCP,
});

// Create Service
const service = new ecs.Ec2Service(stack, "Service", {
const service = new ecs.Ec2Service(stack, 'Service', {
cluster,
taskDefinition,
});
Expand Down
Loading