Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Dec 5, 2022
2 parents 668d526 + fe08aa9 commit 93ffbd5
Show file tree
Hide file tree
Showing 12 changed files with 2,175 additions and 168 deletions.
7 changes: 7 additions & 0 deletions packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts
Expand Up @@ -408,6 +408,13 @@ export enum SpotAllocationStrategy {
* honors the instance type priorities on a best-effort basis but optimizes for capacity first.
*/
CAPACITY_OPTIMIZED_PRIORITIZED = 'capacity-optimized-prioritized',

/**
* The price and capacity optimized allocation strategy looks at both price and
* capacity to select the Spot Instance pools that are the least likely to be
* interrupted and have the lowest possible price.
*/
PRICE_CAPACITY_OPTIMIZED = 'price-capacity-optimized',
}

/**
Expand Down
41 changes: 41 additions & 0 deletions packages/@aws-cdk/aws-autoscaling/test/auto-scaling-group.test.ts
Expand Up @@ -1915,6 +1915,47 @@ test('can use Vpc imported from unparseable list tokens', () => {
});
});

test('add price-capacity-optimized', () => {
// GIVEN
const stack = new cdk.Stack();

// WHEN
const lt = LaunchTemplate.fromLaunchTemplateAttributes(stack, 'imported-lt', {
launchTemplateId: 'test-lt-id',
versionNumber: '0',
});

new autoscaling.AutoScalingGroup(stack, 'mip-asg', {
mixedInstancesPolicy: {
launchTemplate: lt,
launchTemplateOverrides: [{
instanceType: new InstanceType('t4g.micro'),
launchTemplate: lt,
weightedCapacity: 9,
}],
instancesDistribution: {
onDemandAllocationStrategy: OnDemandAllocationStrategy.PRIORITIZED,
onDemandBaseCapacity: 1,
onDemandPercentageAboveBaseCapacity: 2,
spotAllocationStrategy: SpotAllocationStrategy.PRICE_CAPACITY_OPTIMIZED,
spotInstancePools: 3,
spotMaxPrice: '4',
},
},
vpc: mockVpc(stack),
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::AutoScaling::AutoScalingGroup', {
MixedInstancesPolicy: {
InstancesDistribution: {
SpotAllocationStrategy: 'price-capacity-optimized',
},
},
});
});


function mockSecurityGroup(stack: cdk.Stack) {
return ec2.SecurityGroup.fromSecurityGroupId(stack, 'MySG', 'most-secure');
}
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-glue/README.md
Expand Up @@ -45,7 +45,7 @@ An ETL job processes data in batches using Apache Spark.
declare const bucket: s3.Bucket;
new glue.Job(this, 'ScalaSparkEtlJob', {
executable: glue.JobExecutable.scalaEtl({
glueVersion: glue.GlueVersion.V2_0,
glueVersion: glue.GlueVersion.V4_0,
script: glue.Code.fromBucket(bucket, 'src/com/example/HelloWorld.scala'),
className: 'com.example.HelloWorld',
extraJars: [glue.Code.fromBucket(bucket, 'jars/HelloWorld.jar')],
Expand All @@ -61,7 +61,7 @@ A Streaming job is similar to an ETL job, except that it performs ETL on data st
```ts
new glue.Job(this, 'PythonSparkStreamingJob', {
executable: glue.JobExecutable.pythonStreaming({
glueVersion: glue.GlueVersion.V2_0,
glueVersion: glue.GlueVersion.V4_0,
pythonVersion: glue.PythonVersion.THREE,
script: glue.Code.fromAsset(path.join(__dirname, 'job-script/hello_world.py')),
}),
Expand Down
7 changes: 6 additions & 1 deletion packages/@aws-cdk/aws-glue/lib/job-executable.ts
Expand Up @@ -29,6 +29,11 @@ export class GlueVersion {
*/
public static readonly V3_0 = new GlueVersion('3.0');

/**
* Glue version using Spark 3.3.0 and Python 3.10
*/
public static readonly V4_0 = new GlueVersion('4.0');

/**
* Custom Glue version
* @param version custom version
Expand Down Expand Up @@ -292,7 +297,7 @@ export class JobExecutable {
if (config.language !== JobLanguage.PYTHON) {
throw new Error('Python shell requires the language to be set to Python');
}
if ([GlueVersion.V0_9, GlueVersion.V2_0, GlueVersion.V3_0].includes(config.glueVersion)) {
if ([GlueVersion.V0_9, GlueVersion.V2_0, GlueVersion.V3_0, GlueVersion.V4_0].includes(config.glueVersion)) {
throw new Error(`Specified GlueVersion ${config.glueVersion.name} does not support Python Shell`);
}
}
Expand Down
@@ -1,5 +1,5 @@
{
"version": "21.0.0",
"version": "22.0.0",
"files": {
"432033e3218068a915d2532fa9be7858a12b228a2ae6e5c10faccd9097b1e855": {
"source": {
Expand All @@ -14,15 +14,15 @@
}
}
},
"3d4fb124b6f262a7f5f621715b1437dcf5af3450121d622990f89e94fd55d8f5": {
"0985af21379e9d6e1cba091105ecb533ee38a96b4c738816daf17d951a0752b4": {
"source": {
"path": "aws-glue-job.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "3d4fb124b6f262a7f5f621715b1437dcf5af3450121d622990f89e94fd55d8f5.json",
"objectKey": "0985af21379e9d6e1cba091105ecb533ee38a96b4c738816daf17d951a0752b4.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down

0 comments on commit 93ffbd5

Please sign in to comment.