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

chore(release): 1.93.0 #13542

Merged
merged 41 commits into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4e03667
chore(merge-back): 1.92.0 (#13432)
mergify[bot] Mar 6, 2021
6a5a4f2
feat(dynamodb): custom timeout for replication operation (#13354)
jogold Mar 8, 2021
5cc3774
chore(dynamodb-global): use NODEJS_14_X in GlobalTableCoordinator (#1…
robertd Mar 8, 2021
6c5b1f4
feat(neptune): Support IAM authentication (#13462)
christophgysin Mar 8, 2021
0ebcb41
feat(events): dead-letter queue support for StepFunctions (#13450)
DaWyz Mar 8, 2021
56c2029
docs(pipelines): fix code examples (#13401)
tjenkinson Mar 8, 2021
b3fba43
feat(region-info): added AppMesh ECR account for af-south-1 region (#…
JayntiRaj Mar 8, 2021
90dbfb5
fix(iam): oidc-provider can't pull from hosts requiring SNI (#13397)
creiche Mar 8, 2021
faa0c06
feat(iam): SAML identity provider (#13393)
jogold Mar 8, 2021
ed94c5e
feat(ec2): multipart user data (#11843)
rsmogura Mar 8, 2021
191c54d
docs: Small typo fix in README.md of aws-ecr (#13433)
nelsonjchen Mar 8, 2021
d9d58af
docs(s3): update ID of the example encrypted bucket in the ReadMe (#1…
maoshouse Mar 8, 2021
e567a41
feat(ecs): ability to access tag parameter value of TagParameterConta…
alastair-watts-avrios Mar 8, 2021
e09250b
feat(codebuild): allow setting queued timeout (#13467)
ialford Mar 8, 2021
57e5404
fix(events): imported EventBus does not correctly register source acc…
thantos Mar 9, 2021
960189c
docs(stepfunctions-tasks): fix up all code snippets so they compile (…
shivlaks Mar 9, 2021
e08213f
chore(cloudfront): check size of the Cache Policy headers (#13425)
robertd Mar 9, 2021
abfc0ea
feat(events): dead-letter queue support for CodeBuild (#13448)
DaWyz Mar 9, 2021
f5a6647
feat(ec2): ESP and AH IPsec protocols for Security Groups (#13471)
hollanddd Mar 9, 2021
122a232
feat(events): `EventBus.grantPutEventsTo` method for granular grants …
DaWyz Mar 9, 2021
781aa97
fix(ec2): fix typo's in WindowsImage constants (#13446)
robertd Mar 9, 2021
b1449a1
feat(events,applicationautoscaling): schedule can be a token (#13064)
sneharathod Mar 9, 2021
01b94f8
fix(elasticloadbalancingv2): upgrade to v1.92.0 drops certificates on…
njlynch Mar 9, 2021
6c3d407
fix(stepfunctions): no validation on state machine name (#13387)
jonnekaunisto Mar 9, 2021
c4dc3bc
feat(ecr): add imageTagMutability prop (#10557)
ap00rv Mar 9, 2021
a7d314c
feat(ecs): allow users to provide a CloudMap service to associate wit…
misterjoshua Mar 9, 2021
40295d2
chore(neptune): update readme to work with default fixture (#13477)
cornerwings Mar 9, 2021
9910f77
docs(certificatemanager): Fix typo 'ExampelNet' -> 'ExampleNet' (#13319)
nicolaifsf Mar 9, 2021
3f1c02d
fix(init): Python init template's stack ID doesn't match other langua…
Mar 10, 2021
e5dab7c
fix(cfn-include): allow boolean values for string-typed properties (#…
skinny85 Mar 10, 2021
7711981
feat(cfnspec): cloudformation spec v30.1.0 (#13519)
aws-cdk-automation Mar 10, 2021
8dca507
chore(core): update CDK Metadata to report construct-level details (#…
njlynch Mar 10, 2021
bc1293b
refactor(core): refactor `CloudFormationLang.toJSON()` (#11224)
rix0rrr Mar 10, 2021
e635dac
chore: change the parameter used for 'find' in link-all.sh (#13510)
skinny85 Mar 10, 2021
8d592ea
fix(iam): policy statement tries to validate tokens (#13493)
hollanddd Mar 10, 2021
78b265c
chore(aws-cdk-lib): change namespaces/package names in line with RFC …
rix0rrr Mar 10, 2021
cc608d0
feat(stepfunctions-tasks): Support calling ApiGateway REST and HTTP A…
ayush987goyal Mar 10, 2021
66f7053
feat(appmesh): add route retry policies (#13353)
misterjoshua Mar 11, 2021
4c63f09
feat(amplify-domain): Added config for auto subdomain creation (#13342)
janario Mar 11, 2021
e9cd1e8
chore(test): make metadata resource test immune to encoding (#13538)
RomainMuller Mar 11, 2021
b5d4b92
chore(release): 1.93.0
Mar 11, 2021
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
1 change: 1 addition & 0 deletions .gitallowed
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ account: '772975370895'
account: '856666278305'
account: '840364872350'
account: '422531588944'
account: '924023996002'
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,42 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.93.0](https://github.com/aws/aws-cdk/compare/v1.92.0...v1.93.0) (2021-03-11)


### Features

* **amplify-domain:** Added config for auto subdomain creation ([#13342](https://github.com/aws/aws-cdk/issues/13342)) ([4c63f09](https://github.com/aws/aws-cdk/commit/4c63f09f1e9644877eaffbe78eede3854bec08ab))
* **appmesh:** add route retry policies ([#13353](https://github.com/aws/aws-cdk/issues/13353)) ([66f7053](https://github.com/aws/aws-cdk/commit/66f7053a6c1f5cab540e975b30f5a2c6e35df58a)), closes [#11642](https://github.com/aws/aws-cdk/issues/11642)
* **cfnspec:** cloudformation spec v30.1.0 ([#13519](https://github.com/aws/aws-cdk/issues/13519)) ([7711981](https://github.com/aws/aws-cdk/commit/7711981ea30bfdffd21dd840d676be4a2b45c9ba))
* **codebuild:** allow setting queued timeout ([#13467](https://github.com/aws/aws-cdk/issues/13467)) ([e09250b](https://github.com/aws/aws-cdk/commit/e09250bc92c62cb8ee0a8706ce90d0e82faf2d84)), closes [#11364](https://github.com/aws/aws-cdk/issues/11364)
* **dynamodb:** custom timeout for replication operation ([#13354](https://github.com/aws/aws-cdk/issues/13354)) ([6a5a4f2](https://github.com/aws/aws-cdk/commit/6a5a4f2d9bb6b09ad0d10066200fe53bb45f0737)), closes [#10249](https://github.com/aws/aws-cdk/issues/10249)
* **ec2:** ESP and AH IPsec protocols for Security Groups ([#13471](https://github.com/aws/aws-cdk/issues/13471)) ([f5a6647](https://github.com/aws/aws-cdk/commit/f5a6647bbe1885ba86029d10550a3ffaf80b6561)), closes [#13403](https://github.com/aws/aws-cdk/issues/13403)
* **ec2:** multipart user data ([#11843](https://github.com/aws/aws-cdk/issues/11843)) ([ed94c5e](https://github.com/aws/aws-cdk/commit/ed94c5ef1b9dd3042128b0e0c5bb14b3d9c7d497)), closes [#8315](https://github.com/aws/aws-cdk/issues/8315)
* **ecr:** add imageTagMutability prop ([#10557](https://github.com/aws/aws-cdk/issues/10557)) ([c4dc3bc](https://github.com/aws/aws-cdk/commit/c4dc3bce02790903593d80b070fca81fe7b7f08c)), closes [#4640](https://github.com/aws/aws-cdk/issues/4640)
* **ecs:** ability to access tag parameter value of TagParameterContainerImage ([#13340](https://github.com/aws/aws-cdk/issues/13340)) ([e567a41](https://github.com/aws/aws-cdk/commit/e567a410d47366855ee3e6011aa096ba987b8099)), closes [#13202](https://github.com/aws/aws-cdk/issues/13202)
* **ecs:** allow users to provide a CloudMap service to associate with an ECS service ([#13192](https://github.com/aws/aws-cdk/issues/13192)) ([a7d314c](https://github.com/aws/aws-cdk/commit/a7d314c73b9473208d94bac29ad9bd8018e00204)), closes [#10057](https://github.com/aws/aws-cdk/issues/10057)
* **events:** `EventBus.grantPutEventsTo` method for granular grants ([#13429](https://github.com/aws/aws-cdk/issues/13429)) ([122a232](https://github.com/aws/aws-cdk/commit/122a232343699304d8f206d3024fcddfb2a94bc8)), closes [#11228](https://github.com/aws/aws-cdk/issues/11228)
* **events:** dead-letter queue support for CodeBuild ([#13448](https://github.com/aws/aws-cdk/issues/13448)) ([abfc0ea](https://github.com/aws/aws-cdk/commit/abfc0ea63c10d8033a529b7497cf093e318fdf12)), closes [#13447](https://github.com/aws/aws-cdk/issues/13447)
* **events:** dead-letter queue support for StepFunctions ([#13450](https://github.com/aws/aws-cdk/issues/13450)) ([0ebcb41](https://github.com/aws/aws-cdk/commit/0ebcb4160ee16f0f7ff1072a40c8951f9a983048)), closes [#13449](https://github.com/aws/aws-cdk/issues/13449)
* **events,applicationautoscaling:** schedule can be a token ([#13064](https://github.com/aws/aws-cdk/issues/13064)) ([b1449a1](https://github.com/aws/aws-cdk/commit/b1449a178b0f9a8a951c2546428f8d75c6431f0f))
* **iam:** SAML identity provider ([#13393](https://github.com/aws/aws-cdk/issues/13393)) ([faa0c06](https://github.com/aws/aws-cdk/commit/faa0c060dad9a5045495707e28fc85f223d4db5d)), closes [#5320](https://github.com/aws/aws-cdk/issues/5320)
* **neptune:** Support IAM authentication ([#13462](https://github.com/aws/aws-cdk/issues/13462)) ([6c5b1f4](https://github.com/aws/aws-cdk/commit/6c5b1f42fb73a132d47945b529bab73557f2b9d8)), closes [#13461](https://github.com/aws/aws-cdk/issues/13461)
* **region-info:** added AppMesh ECR account for af-south-1 region ([#12814](https://github.com/aws/aws-cdk/issues/12814)) ([b3fba43](https://github.com/aws/aws-cdk/commit/b3fba43a047df61e713e8d2271d6deee7e07b716))
* **stepfunctions-tasks:** Support calling ApiGateway REST and HTTP APIs ([#13033](https://github.com/aws/aws-cdk/issues/13033)) ([cc608d0](https://github.com/aws/aws-cdk/commit/cc608d055ffefb798ad6378ab07f36cb241897da)), closes [#11565](https://github.com/aws/aws-cdk/issues/11565) [#11566](https://github.com/aws/aws-cdk/issues/11566) [#11565](https://github.com/aws/aws-cdk/issues/11565)


### Bug Fixes

* **cfn-include:** allow boolean values for string-typed properties ([#13508](https://github.com/aws/aws-cdk/issues/13508)) ([e5dab7c](https://github.com/aws/aws-cdk/commit/e5dab7cbc67c234d191c38a8b8b84b634070b15b))
* **ec2:** fix typo's in WindowsImage constants ([#13446](https://github.com/aws/aws-cdk/issues/13446)) ([781aa97](https://github.com/aws/aws-cdk/commit/781aa97d53fdb7511c34ddde884fdcd84c3f68a6))
* **elasticloadbalancingv2:** upgrade to v1.92.0 drops certificates on ALB if more than 2 certificates exist ([#13490](https://github.com/aws/aws-cdk/issues/13490)) ([01b94f8](https://github.com/aws/aws-cdk/commit/01b94f8aa6c88b5e676c784aec4c879acddc042f)), closes [#13332](https://github.com/aws/aws-cdk/issues/13332) [#13437](https://github.com/aws/aws-cdk/issues/13437)
* **events:** imported EventBus does not correctly register source account ([#13481](https://github.com/aws/aws-cdk/issues/13481)) ([57e5404](https://github.com/aws/aws-cdk/commit/57e540432c1446f2233a9b0c0f4caba4e9e155d9)), closes [#13469](https://github.com/aws/aws-cdk/issues/13469)
* **iam:** oidc-provider can't pull from hosts requiring SNI ([#13397](https://github.com/aws/aws-cdk/issues/13397)) ([90dbfb5](https://github.com/aws/aws-cdk/commit/90dbfb5eec19559717ac6b30f25451461027e731))
* **iam:** policy statement tries to validate tokens ([#13493](https://github.com/aws/aws-cdk/issues/13493)) ([8d592ea](https://github.com/aws/aws-cdk/commit/8d592ea89c0eda19329d5a31517522ec02ceb874)), closes [#13479](https://github.com/aws/aws-cdk/issues/13479)
* **init:** Python init template's stack ID doesn't match other languages ([#13480](https://github.com/aws/aws-cdk/issues/13480)) ([3f1c02d](https://github.com/aws/aws-cdk/commit/3f1c02dac7a50ce7caebce1e7f8953f6e4937e6b))
* **stepfunctions:** no validation on state machine name ([#13387](https://github.com/aws/aws-cdk/issues/13387)) ([6c3d407](https://github.com/aws/aws-cdk/commit/6c3d4071746179dde30f615602592c2523daa56e)), closes [#13289](https://github.com/aws/aws-cdk/issues/13289)

## [1.92.0](https://github.com/aws/aws-cdk/compare/v1.91.0...v1.92.0) (2021-03-06)

* **ecs-patterns**: the `desiredCount` property stored on the above constructs will be optional, allowing them to be undefined. This is enabled through the `@aws-cdk/aws-ecs-patterns:removeDefaultDesiredCount` feature flag. We would recommend all CDK users to set the `@aws-cdk/aws-ecs-patterns:removeDefaultDesiredCount` flag to `true` for all of their existing applications.
Expand Down
2 changes: 1 addition & 1 deletion link-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ for module in ${modules}; do
# according to spec (we look in the bin/ directory instead of the { "scripts"
# } entry in package.json but it's quite a bit easier.
if [[ -d $module/bin ]]; then
for script in $(find $module/bin -perm /111); do
for script in $(find $module/bin -perm +111); do
echo "${script} => node_modules/.bin/$(basename $script)"
ln -fs ${script} node_modules/.bin
done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export class AppMeshExtension extends ServiceExtension {

'me-south-1': this.accountIdForRegion('me-south-1'),
'ap-east-1': this.accountIdForRegion('ap-east-1'),
'af-south-1': this.accountIdForRegion('af-south-1'),
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3354,6 +3354,9 @@
},
"ap-east-1": {
"ecrRepo": "856666278305"
},
"af-south-1": {
"ecrRepo": "924023996002"
}
},
"greetingenvoyimageaccountmapping": {
Expand Down Expand Up @@ -3413,6 +3416,9 @@
},
"ap-east-1": {
"ecrRepo": "856666278305"
},
"af-south-1": {
"ecrRepo": "924023996002"
}
},
"greeterenvoyimageaccountmapping": {
Expand Down Expand Up @@ -3472,6 +3478,9 @@
},
"ap-east-1": {
"ecrRepo": "856666278305"
},
"af-south-1": {
"ecrRepo": "924023996002"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2173,6 +2173,9 @@
},
"ap-east-1": {
"ecrRepo": "856666278305"
},
"af-south-1": {
"ecrRepo": "924023996002"
}
},
"namedevelopmentenvoyimageaccountmapping": {
Expand Down Expand Up @@ -2232,6 +2235,9 @@
},
"ap-east-1": {
"ecrRepo": "856666278305"
},
"af-south-1": {
"ecrRepo": "924023996002"
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion packages/@aws-cdk/aws-amplify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ mySinglePageApp.addCustomRule(amplify.CustomRule.SINGLE_PAGE_APPLICATION_REDIREC
Add a domain and map sub domains to branches:

```ts
const domain = amplifyApp.addDomain('example.com');
const domain = amplifyApp.addDomain('example.com', {
enableAutoSubdomain: true, // in case subdomains should be auto registered for branches
autoSubdomainCreationPatterns: ['*', 'pr*'], // regex for branches that should auto register subdomains
});
domain.mapRoot(master); // map master branch to domain root
domain.mapSubDomain(master, 'www');
domain.mapSubDomain(dev); // sub domain prefix defaults to branch name
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-amplify/lib/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ export class App extends Resource implements IApp, iam.IGrantable {
return new Domain(this, id, {
...options,
app: this,
autoSubDomainIamRole: this.grantPrincipal as iam.IRole,
});
}
}
Expand Down
24 changes: 24 additions & 0 deletions packages/@aws-cdk/aws-amplify/lib/domain.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as iam from '@aws-cdk/aws-iam';
import { Lazy, Resource, IResolvable } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnDomain } from './amplify.generated';
Expand All @@ -21,6 +22,20 @@ export interface DomainOptions {
* @default - use `addSubDomain()` to add subdomains
*/
readonly subDomains?: SubDomain[];

/**
* Automatically create subdomains for connected branches
*
* @default false
*/
readonly enableAutoSubdomain?: boolean;

/**
* Branches which should automatically create subdomains
*
* @default - all repository branches ['*', 'pr*']
*/
readonly autoSubdomainCreationPatterns?: string[];
}

/**
Expand All @@ -31,6 +46,12 @@ export interface DomainProps extends DomainOptions {
* The application to which the domain must be connected
*/
readonly app: IApp;

/**
* The IAM role with access to Route53 when using enableAutoSubdomain
* @default the IAM role from App.grantPrincipal
*/
readonly autoSubDomainIamRole?: iam.IRole;
}

/**
Expand Down Expand Up @@ -106,6 +127,9 @@ export class Domain extends Resource {
appId: props.app.appId,
domainName,
subDomainSettings: Lazy.any({ produce: () => this.renderSubDomainSettings() }, { omitEmptyArray: true }),
enableAutoSubDomain: !!props.enableAutoSubdomain,
autoSubDomainCreationPatterns: props.autoSubdomainCreationPatterns || ['*', 'pr*'],
autoSubDomainIamRole: props.autoSubDomainIamRole?.roleArn,
});

this.arn = domain.attrArn;
Expand Down
111 changes: 111 additions & 0 deletions packages/@aws-cdk/aws-amplify/test/domain.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as iam from '@aws-cdk/aws-iam';
import '@aws-cdk/assert/jest';
import { App, SecretValue, Stack } from '@aws-cdk/core';
import * as amplify from '../lib';
Expand Down Expand Up @@ -120,3 +121,113 @@ test('throws at synthesis without subdomains', () => {
// THEN
expect(() => app.synth()).toThrow(/The domain doesn't contain any subdomains/);
});

test('auto subdomain all branches', () => {
// GIVEN
const stack = new Stack();
const app = new amplify.App(stack, 'App', {
sourceCodeProvider: new amplify.GitHubSourceCodeProvider({
owner: 'aws',
repository: 'aws-cdk',
oauthToken: SecretValue.plainText('secret'),
}),
});
const prodBranch = app.addBranch('master');

// WHEN
const domain = app.addDomain('amazon.com', {
enableAutoSubdomain: true,
});
domain.mapRoot(prodBranch);

// THEN
expect(stack).toHaveResource('AWS::Amplify::Domain', {
EnableAutoSubDomain: true,
AutoSubDomainCreationPatterns: [
'*',
'pr*',
],
AutoSubDomainIAMRole: {
'Fn::GetAtt': [
'AppRole1AF9B530',
'Arn',
],
},
});
});

test('auto subdomain some branches', () => {
// GIVEN
const stack = new Stack();
const app = new amplify.App(stack, 'App', {
sourceCodeProvider: new amplify.GitHubSourceCodeProvider({
owner: 'aws',
repository: 'aws-cdk',
oauthToken: SecretValue.plainText('secret'),
}),
});
const prodBranch = app.addBranch('master');

// WHEN
const domain = app.addDomain('amazon.com', {
enableAutoSubdomain: true,
autoSubdomainCreationPatterns: ['features/**'],
});
domain.mapRoot(prodBranch);

// THEN
expect(stack).toHaveResource('AWS::Amplify::Domain', {
EnableAutoSubDomain: true,
AutoSubDomainCreationPatterns: ['features/**'],
AutoSubDomainIAMRole: {
'Fn::GetAtt': [
'AppRole1AF9B530',
'Arn',
],
},
});
});

test('auto subdomain with IAM role', () => {
// GIVEN
const stack = new Stack();
const app = new amplify.App(stack, 'App', {
sourceCodeProvider: new amplify.GitHubSourceCodeProvider({
owner: 'aws',
repository: 'aws-cdk',
oauthToken: SecretValue.plainText('secret'),
}),
role: iam.Role.fromRoleArn(
stack,
'AmplifyRole',
`arn:aws:iam::${Stack.of(stack).account}:role/AmplifyRole`,
{ mutable: false },
),
});
const prodBranch = app.addBranch('master');

// WHEN
const domain = app.addDomain('amazon.com', {
enableAutoSubdomain: true,
autoSubdomainCreationPatterns: ['features/**'],
});
domain.mapRoot(prodBranch);

// THEN
expect(stack).toHaveResource('AWS::Amplify::Domain', {
EnableAutoSubDomain: true,
AutoSubDomainCreationPatterns: ['features/**'],
AutoSubDomainIAMRole: {
'Fn::Join': [
'',
[
'arn:aws:iam::',
{
Ref: 'AWS::AccountId',
},
':role/AmplifyRole',
],
],
},
});
});
7 changes: 7 additions & 0 deletions packages/@aws-cdk/aws-applicationautoscaling/lib/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ export abstract class Schedule {
* Construct a schedule from an interval and a time unit
*/
public static rate(duration: Duration): Schedule {
const validDurationUnit = ['minute', 'minutes', 'hour', 'hours', 'day', 'days'];
if (!validDurationUnit.includes(duration.unitLabel())) {
throw new Error("Allowed unit for scheduling is: 'minute', 'minutes', 'hour', 'hours', 'day' or 'days'");
}
if (duration.isUnresolved()) {
return new LiteralSchedule(`rate(${duration.formatTokenToNumber()})`);
}
if (duration.toSeconds() === 0) {
throw new Error('Duration cannot be 0');
}
Expand Down
27 changes: 24 additions & 3 deletions packages/@aws-cdk/aws-applicationautoscaling/test/test.cron.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Duration } from '@aws-cdk/core';
import { Duration, Stack, Lazy } from '@aws-cdk/core';
import { Test } from 'nodeunit';
import * as appscaling from '../lib';

Expand All @@ -15,8 +15,15 @@ export = {

'rate must be whole number of minutes'(test: Test) {
test.throws(() => {
appscaling.Schedule.rate(Duration.seconds(12345));
}, /'12345 seconds' cannot be converted into a whole number of minutes/);
appscaling.Schedule.rate(Duration.minutes(0.13456));
}, /'0.13456 minutes' cannot be converted into a whole number of seconds/);
test.done();
},

'rate must not be in seconds'(test: Test) {
test.throws(() => {
appscaling.Schedule.rate(Duration.seconds(1));
}, /Allowed unit for scheduling is: 'minute', 'minutes', 'hour', 'hours', 'day' or 'days'/);
test.done();
},

Expand All @@ -26,4 +33,18 @@ export = {
}, /Duration cannot be 0/);
test.done();
},

'rate can be token'(test: Test) {
const stack = new Stack();
const lazyDuration = Duration.minutes(Lazy.number({ produce: () => 5 }));
const rate = appscaling.Schedule.rate(lazyDuration);
test.equal('rate(5 minutes)', stack.resolve(rate).expressionString);
test.done();
},

'rate can be in allowed type hours'(test: Test) {
test.equal('rate(1 hour)', appscaling.Schedule.rate(Duration.hours(1))
.expressionString);
test.done();
},
};
Loading