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

feat(stepfunctions-tasks): adding on demand option + allocation s… #12512

Closed
wants to merge 63 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
e5a8b5e
feat(aws-stepfunctions-tasks): adding on demand option + allocation s…
Jan 14, 2021
df49eb6
chore(release): 1.85.0
Jan 14, 2021
fe5ee19
Update CHANGELOG.md
NetaNir Jan 14, 2021
ed2ef5c
Update CHANGELOG.md
NetaNir Jan 14, 2021
3d51bc8
Update CHANGELOG.md
NetaNir Jan 14, 2021
c824c2f
Update CHANGELOG.md
NetaNir Jan 14, 2021
51c53df
chore(deps-dev): bump typescript-json-schema from 0.46.0 to 0.47.0 (#…
dependabot-preview[bot] Jan 14, 2021
d79f1a1
chore: eliminate the use of `xxx.Construct` to reduce v2 merge confli…
Jan 15, 2021
b9eb38a
chore(deps): bump aws-sdk from 2.827.0 to 2.828.0 (#12533)
dependabot-preview[bot] Jan 15, 2021
d05c98e
chore(aws-cdk-lib): minimum supported node version is now v14 (#11964)
Jan 15, 2021
b8e39b2
chore(scripts): compat check will compare against last published vers…
Jan 15, 2021
33fc397
chore(eks): updated the eks launch template support topic in the docs…
dirknilius Jan 15, 2021
89cf902
chore(pkglint): validate that package `maturity` is correct (#12519)
skinny85 Jan 15, 2021
0a9d636
docs(codebuild): clarify BuildEnvironmentVariable `value` property (#…
blimmer Jan 15, 2021
4d79453
chore: switch to using yarn in package.json scripts (#12530)
Jan 17, 2021
e752d2a
chore(lambda-layer-kubectl): fix readme to refer to the correct modul…
iliapolo Jan 17, 2021
dc8248a
feat(elasticsearch): UltraWarm nodes (#12265)
jumi-dev Jan 17, 2021
f044f2e
chore(deps-dev): bump esbuild from 0.8.32 to 0.8.33 (#12560)
dependabot-preview[bot] Jan 18, 2021
a11a228
chore(deps): bump @typescript-eslint/eslint-plugin from 4.12.0 to 4.1…
dependabot-preview[bot] Jan 18, 2021
83d3dbd
docs: note that `cdk.context.json` must be committed (#12565)
rix0rrr Jan 18, 2021
39aa43b
chore(deps-dev): bump @types/node from 10.17.48 to 10.17.51 (#12571)
dependabot-preview[bot] Jan 18, 2021
ed6777b
chore(ec2): add c6gn instance type metadata (#12525)
Jacob-Doetsch Jan 18, 2021
7461d16
fix(iam): Groups are erroneously accepted as the Principal of a polic…
swar8080 Jan 18, 2021
3c84890
chore(deps-dev): bump @types/lodash from 4.14.167 to 4.14.168 (#12578)
dependabot-preview[bot] Jan 18, 2021
3e236df
chore(deps): bump @typescript-eslint/eslint-plugin from 4.13.0 to 4.1…
dependabot-preview[bot] Jan 18, 2021
1d064d0
chore(applicationautoscaling): Add MSK storage scaling predefined met…
Jan 19, 2021
fcfd46f
fix(ec2): Vpc.fromVpcAttributes cannot be used with EKS (#12569)
rix0rrr Jan 19, 2021
7f67d2c
chore(core): stack.test.ts is now using jest (#12596)
Jan 19, 2021
c0abdaa
chore: compat check does not correctly resolve baseline version in re…
Jan 20, 2021
cb50af5
chore: install integ tests dependencies using npm7 (#12626)
rix0rrr Jan 20, 2021
85b2e57
chore: encode npm disttag in version resolution (#12627)
Jan 20, 2021
019a51c
feat(cognito): allow to set read and write attributes in Cognito User…
tom139 Jan 20, 2021
4378dde
docs(codepipeline-actions): fix typo in Readme (#12625)
sergeant-wizard Jan 20, 2021
c2c55da
docs(s3-deployment): fix missing brackets in the code example of prun…
minchao Jan 20, 2021
9dc95ca
feat(s3): Bucket keys (#12376)
bweigel Jan 20, 2021
920d8f8
fix(aws-ecs): Invalid user data defined for windows autoscaling group…
phillipCouto Jan 20, 2021
9fc2c2b
fix(apigateway): cannot remove first api key from usage plan (#12505)
Jan 21, 2021
4dc0e24
fix(synthetics): default execution role breaks in non aws partitions …
Khufu-I Jan 21, 2021
b9848d5
feat(ec2): Support for new EBS types (#12074)
leandrodamascena Jan 21, 2021
dbaef03
feat(cfnspec): cloudformation spec v24.0.0 (#12615)
aws-cdk-automation Jan 21, 2021
37e0fbe
chore(deps): bump proxy-agent from 4.0.0 to 4.0.1 (#12591)
dependabot-preview[bot] Jan 21, 2021
64d8ed1
chore: remove strong-named key references and signing for .NET (#12632)
njlynch Jan 21, 2021
057a1c7
chore(release): 1.86.0
Jan 21, 2021
949bd7e
feat(eks): Graduate to stable (#12640)
iliapolo Jan 21, 2021
37bc501
chore(deps): bump fs-extra from 9.0.1 to 9.1.0 (#12641)
dependabot-preview[bot] Jan 21, 2021
86c1257
fix(core): modern deployments fail if bootstrap stack is renamed (#12…
rix0rrr Jan 21, 2021
4668797
docs(ecs): typo in docstring (#12621)
ppbdrinker Jan 21, 2021
9d8807e
chore(integtests): make installing NPM7 safe against concurrent calls…
rix0rrr Jan 21, 2021
f4e2db1
chore: deprecate app-delivery and EKS-legacy modules (#12545)
skinny85 Jan 21, 2021
a61cf20
chore(deps): bump aws-sdk from 2.828.0 to 2.830.0 (#12650)
dependabot-preview[bot] Jan 21, 2021
11e44b2
fix(s3-deployment): User metadata keys have redundant triple `x-amz` …
bmwalters Jan 21, 2021
abec497
feat(aws-codepipeline-actions): Add Full Clone support for CodeCommit…
DaWyz Jan 21, 2021
ad91ccc
chore(deps-dev): bump esbuild from 0.8.33 to 0.8.34 (#12653)
dependabot-preview[bot] Jan 22, 2021
940abd1
docs(stepfunctions-tasks): Replace deprecated class name (#12658)
JacobAMason Jan 22, 2021
0375f4c
feat(stepfunctions-tasks): EcsRunTask now uses taskDefinition family …
ayush987goyal Jan 22, 2021
e74f61b
chore: tests fail on a machine with a `~/.cdk.json` file (#12579)
rix0rrr Jan 22, 2021
d873d51
fix(apigatewayv2): multiple http integrations are created for each ro…
ayush987goyal Jan 22, 2021
9084d8a
chore: remove unused dependencies on the @aws-cdk/assets module (#12652)
skinny85 Jan 22, 2021
6e2c031
chore: introduce special logic for unit tests that rely on feature fl…
Jan 22, 2021
58d395c
feat(aws-stepfunctions-tasks): adding on demand option + allocation s…
Jan 14, 2021
b4d8a0e
Merge branch 'master' into master
mohanrajendran Jan 24, 2021
21a7d30
Merge branch 'master' into master
mohanrajendran Jan 26, 2021
51de8a2
Merge branch 'master' into master
mohanrajendran Feb 14, 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
Original file line number Diff line number Diff line change
Expand Up @@ -563,13 +563,48 @@ export namespace EmrCreateCluster {
}

/**
* The launch specification for Spot instances in the instance fleet, which determines the defined duration and provisioning timeout behavior.
* Different allocation strategies that can be used by the EMR cluster
*/
export class AllocationStrategy {
/** lowest-price allocation strategy. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include a link to the docs - ideally we want to provide more information to users to determine which allocation is most appropriate for their use case(s)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, added link to the Cfn docs.

public static readonly LOWEST_PRICE = new AllocationStrategy('lowest-price');
/** capacity-optimized allocation strategy */
public static readonly CAPACITY_OPTIMIZED = new AllocationStrategy('capacity-optimized');

/**
* Create a new AllocationStrategy with an arbitrary allocation strategy.
*
* @param customAllocationStrategy the allocation strategy string,
* for example "lowest-price"
*/
Comment on lines +574 to +579
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there any docs links we can also point to?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added link to the Cfn docs.

public static of(customAllocationStrategy: string): AllocationStrategy {
return new AllocationStrategy(customAllocationStrategy);
}

/** The name of the allocation strategy to be used in EMR task parameters */
public readonly name: string;

private constructor(name: string) {
this.name = name;
}
}

/**
* The launch specification for Spot Instances in the fleet, which determines the defined duration, provisioning timeout behavior, and allocation strategy.
*
* @see https://docs.aws.amazon.com/emr/latest/APIReference/API_SpotProvisioningSpecification.html
*
* @experimental
*/
export interface SpotProvisioningSpecificationProperty {

/**
* Specifies the strategy to use in launching Spot Instance fleets.
*
* @default AllocationStrategy.CAPACITY_OPTIMIZED
*/
readonly allocationStrategy?: AllocationStrategy;

/**
* The defined duration for Spot instances (also known as Spot blocks) in minutes.
*
Expand All @@ -589,19 +624,46 @@ export namespace EmrCreateCluster {
}

/**
* The launch specification for Spot instances in the fleet, which determines the defined duration and provisioning timeout behavior.
* The launch specification for On-demand instances in the instance fleet, which determines the allocation strategy.
*
* @see https://docs.aws.amazon.com/emr/latest/APIReference/API_OnDemandProvisioningSpecification.html
*
* @experimental
*/
export interface OnDemandProvisioningSpecificationProperty {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming, we generally use Props as a suffix for constructs and Options as a suffix otherwise.
maybe this should be called OnDemandProvisioningOptions or something simpler.

It was a miss and something we should clean up when we drop the experimental for the already existing SpotProvisioningSpecificationProperty interface. But let's not proliferate it further 🙂

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have followed existing conventions of using Property throughout. I think changing this to Props would require changing existing names to Props as well and that would introduce a breaking change.

As for the experimental annotation, its used all over this file, is it fine to remove them all?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, let's leave it alone for now. i'm not a fan of proliferating something we know we want to change because that's the way it's always been done.

but i'm happy to do it in another change. it will break more things, but that's the only way to stop the trend.


/**
* Specifies the strategy to use in launching On-Demand Instance fleets.
*
* @default AllocationStrategy.LOWEST_PRICE
*/
readonly allocationStrategy?: AllocationStrategy;
}

/**
* The launch specification for Spot Instances in the fleet, which determines the defined duration, provisioning timeout behavior, and allocation strategy.
*
* @see https://docs.aws.amazon.com/emr/latest/APIReference/API_InstanceFleetProvisioningSpecifications.html
*
* @experimental
*/
export interface InstanceFleetProvisioningSpecificationsProperty {
/**
* The launch specification for Spot instances in the fleet, which determines the defined duration and provisioning timeout behavior.
* The launch specification for Spot Instances in the fleet, which determines the defined duration, provisioning timeout behavior, and allocation strategy.
*
* @default - None
*/
readonly spotSpecification: SpotProvisioningSpecificationProperty;
readonly spotSpecification?: SpotProvisioningSpecificationProperty;

/**
* The launch specification for On-Demand Instances in the instance fleet, which determines the allocation strategy.
*
* @default - None
*/
readonly onDemandSpecification?: OnDemandProvisioningSpecificationProperty;
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove extra line

/**
* The configuration that defines an instance fleet.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,46 @@ export function InstanceTypeConfigPropertyToJson(property: EmrCreateCluster.Inst
};
}

/**
* Render the SpotProvisioningSpecificationProperty to JSON
*
* @param property
*/
export function SpotProvisioningSpecificationPropertyToJson(property: EmrCreateCluster.SpotProvisioningSpecificationProperty) {
return {
AllocationStrategy: cdk.stringToCloudFormation(property.allocationStrategy?.name),
BlockDurationMinutes: cdk.numberToCloudFormation(property.blockDurationMinutes),
TimeoutAction: cdk.stringToCloudFormation(property.timeoutAction?.valueOf()),
TimeoutDurationMinutes: cdk.numberToCloudFormation(property.timeoutDurationMinutes),
};
}

/**
* Render the SpotProvisioningSpecificationProperty to JSON
*
* @param property
*/
export function OnDemandProvisioningSpecificationPropertyToJson(property: EmrCreateCluster.OnDemandProvisioningSpecificationProperty) {
return {
AllocationStrategy: cdk.stringToCloudFormation(property.allocationStrategy?.name),
};
}

Comment on lines +118 to +142
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do both of these need to be in a utils file? - they're only used in one file. the preference is to keep it local until there's a need (multiple usage sites) to move it to a common location.

/**
* Render the InstanceFleetProvisioningSpecificationsProperty to JSON
*
* @param property
*/
export function InstanceFleetProvisioningSpecificationsPropertyToJson(property: EmrCreateCluster.InstanceFleetProvisioningSpecificationsProperty) {
return {
SpotSpecification: {
BlockDurationMinutes: cdk.numberToCloudFormation(property.spotSpecification.blockDurationMinutes),
TimeoutAction: cdk.stringToCloudFormation(property.spotSpecification.timeoutAction?.valueOf()),
TimeoutDurationMinutes: cdk.numberToCloudFormation(property.spotSpecification.timeoutDurationMinutes),
},
SpotSpecification:
property.spotSpecification === undefined
? property.spotSpecification
: SpotProvisioningSpecificationPropertyToJson(property.spotSpecification),
Comment on lines +150 to +153
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SpotSpecification:
property.spotSpecification === undefined
? property.spotSpecification
: SpotProvisioningSpecificationPropertyToJson(property.spotSpecification),
SpotSpecification: property?.spotSpecification ?? SpotProvisioningSpecificationPropertyToJson(property.spotSpecification,

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be wrong, we don't want to convert to JSON if the field is undefined.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't the function handle that?

OnDemandSpecification:
property.onDemandSpecification === undefined
? property.onDemandSpecification
: OnDemandProvisioningSpecificationPropertyToJson(property.onDemandSpecification),
Comment on lines +154 to +157
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
OnDemandSpecification:
property.onDemandSpecification === undefined
? property.onDemandSpecification
: OnDemandProvisioningSpecificationPropertyToJson(property.onDemandSpecification),
OnDemandSpecification: property?.onDemandSpecification ?? OnDemandProvisioningSpecificationPropertyToJson(property.onDemandSpecification),

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question about the function. can it be more robust to return undefined if the property is undefined?

};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,117 @@ test('Create Cluster with InstanceFleet', () => {
});
});

test('Create Cluster with InstanceFleet OnDemand AllocationStrategy', () => {
// WHEN
const task = new EmrCreateCluster(stack, 'Task', {
instances: {
instanceFleets: [{
instanceFleetType: EmrCreateCluster.InstanceRoleType.MASTER,
instanceTypeConfigs: [{
bidPrice: '1',
bidPriceAsPercentageOfOnDemandPrice: 1,
configurations: [{
classification: 'Classification',
properties: {
Key: 'Value',
},
}],
ebsConfiguration: {
ebsBlockDeviceConfigs: [{
volumeSpecification: {
iops: 1,
volumeSize: cdk.Size.gibibytes(1),
volumeType: EmrCreateCluster.EbsBlockDeviceVolumeType.STANDARD,
},
volumesPerInstance: 1,
}],
ebsOptimized: true,
},
instanceType: 'm5.xlarge',
weightedCapacity: 1,
}],
launchSpecifications: {
onDemandSpecification: {
allocationStrategy: EmrCreateCluster.AllocationStrategy.LOWEST_PRICE,
},
},
name: 'Master',
targetOnDemandCapacity: 1,
targetSpotCapacity: 1,
}],
},
clusterRole,
name: 'Cluster',
serviceRole,
integrationPattern: sfn.IntegrationPattern.REQUEST_RESPONSE,
});

// THEN
expect(stack.resolve(task.toStateJson())).toEqual({
Type: 'Task',
Resource: {
'Fn::Join': [
'',
[
'arn:',
{
Ref: 'AWS::Partition',
},
':states:::elasticmapreduce:createCluster',
],
],
},
End: true,
Parameters: {
Name: 'Cluster',
Instances: {
KeepJobFlowAliveWhenNoSteps: true,
InstanceFleets: [{
InstanceFleetType: 'MASTER',
InstanceTypeConfigs: [{
BidPrice: '1',
BidPriceAsPercentageOfOnDemandPrice: 1,
Configurations: [{
Classification: 'Classification',
Properties: {
Key: 'Value',
},
}],
EbsConfiguration: {
EbsBlockDeviceConfigs: [{
VolumeSpecification: {
Iops: 1,
SizeInGB: 1,
VolumeType: 'standard',
},
VolumesPerInstance: 1,
}],
EbsOptimized: true,
},
InstanceType: 'm5.xlarge',
WeightedCapacity: 1,
}],
LaunchSpecifications: {
OnDemandSpecification: {
AllocationStrategy: 'lowest-price',
},
},
Name: 'Master',
TargetOnDemandCapacity: 1,
TargetSpotCapacity: 1,
}],
},
VisibleToAllUsers: true,
JobFlowRole: {
Ref: 'ClusterRoleD9CA7471',
},
ServiceRole: {
Ref: 'ServiceRole4288B192',
},
},
});
});

test('Create Cluster with InstanceGroup', () => {
// WHEN
const task = new EmrCreateCluster(stack, 'Task', {
Expand Down