Skip to content

Commit

Permalink
Merge branch 'master' into issue11296
Browse files Browse the repository at this point in the history
  • Loading branch information
pgarbe committed Mar 8, 2021
2 parents 27cfcd4 + e09250b commit 2715f0b
Show file tree
Hide file tree
Showing 29 changed files with 1,770 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitallowed
Expand Up @@ -22,3 +22,4 @@ account: '772975370895'
account: '856666278305'
account: '840364872350'
account: '422531588944'
account: '924023996002'
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
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
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
28 changes: 28 additions & 0 deletions packages/@aws-cdk/aws-codebuild/README.md
Expand Up @@ -617,3 +617,31 @@ if (project.enableBatchBuilds()) {
console.log('Batch builds were enabled');
}
```

## Timeouts

There are two types of timeouts that can be set when creating your Project.
The `timeout` property can be used to set an upper limit on how long your Project is able to run without being marked as completed.
The default is 60 minutes.
An example of overriding the default follows.

```ts
import * as codebuild from '@aws-cdk/aws-codebuild';

new codebuild.Project(stack, 'MyProject', {
timeout: Duration.minutes(90)
});
```

The `queuedTimeout` property can be used to set an upper limit on how your Project remains queued to run.
There is no default value for this property.
As an example, to allow your Project to queue for up to thirty (30) minutes before the build fails,
use the following code.

```ts
import * as codebuild from '@aws-cdk/aws-codebuild';

new codebuild.Project(stack, 'MyProject', {
queuedTimeout: Duration.minutes(30)
});
```
10 changes: 10 additions & 0 deletions packages/@aws-cdk/aws-codebuild/lib/project.ts
Expand Up @@ -575,6 +575,15 @@ export interface CommonProjectProps {
* @default - no log configuration is set
*/
readonly logging?: LoggingOptions;

/**
* The number of minutes after which AWS CodeBuild stops the build if it's
* still in queue. For valid values, see the timeoutInMinutes field in the AWS
* CodeBuild User Guide.
*
* @default - no queue timeout is set
*/
readonly queuedTimeout?: Duration
}

export interface ProjectProps extends CommonProjectProps {
Expand Down Expand Up @@ -869,6 +878,7 @@ export class Project extends ProjectBase {
cache: cache._toCloudFormation(),
name: this.physicalName,
timeoutInMinutes: props.timeout && props.timeout.toMinutes(),
queuedTimeoutInMinutes: props.queuedTimeout && props.queuedTimeout.toMinutes(),
secondarySources: Lazy.any({ produce: () => this.renderSecondarySources() }),
secondarySourceVersions: Lazy.any({ produce: () => this.renderSecondarySourceVersions() }),
secondaryArtifacts: Lazy.any({ produce: () => this.renderSecondaryArtifacts() }),
Expand Down
43 changes: 43 additions & 0 deletions packages/@aws-cdk/aws-codebuild/test/test.project.ts
Expand Up @@ -960,4 +960,47 @@ export = {
test.done();
},
},

'Timeouts': {
'can add queued timeout'(test: Test) {
// GIVEN
const stack = new cdk.Stack();

// WHEN
new codebuild.Project(stack, 'Project', {
source: codebuild.Source.s3({
bucket: new s3.Bucket(stack, 'Bucket'),
path: 'path',
}),
queuedTimeout: cdk.Duration.minutes(30),
});

// THEN
expect(stack).to(haveResourceLike('AWS::CodeBuild::Project', {
QueuedTimeoutInMinutes: 30,
}));

test.done();
},
'can override build timeout'(test: Test) {
// GIVEN
const stack = new cdk.Stack();

// WHEN
new codebuild.Project(stack, 'Project', {
source: codebuild.Source.s3({
bucket: new s3.Bucket(stack, 'Bucket'),
path: 'path',
}),
timeout: cdk.Duration.minutes(30),
});

// THEN
expect(stack).to(haveResourceLike('AWS::CodeBuild::Project', {
TimeoutInMinutes: 30,
}));

test.done();
},
},
};
45 changes: 45 additions & 0 deletions packages/@aws-cdk/aws-ec2/README.md
Expand Up @@ -981,6 +981,51 @@ instance.userData.addExecuteFileCommand({
asset.grantRead( instance.role );
```

### Multipart user data

In addition, to above the `MultipartUserData` can be used to change instance startup behavior. Multipart user data are composed
from separate parts forming archive. The most common parts are scripts executed during instance set-up. However, there are other
kinds, too.

The advantage of multipart archive is in flexibility when it's needed to add additional parts or to use specialized parts to
fine tune instance startup. Some services (like AWS Batch) supports only `MultipartUserData`.

The parts can be executed at different moment of instance start-up and can serve a different purposes. This is controlled by `contentType` property.
For common scripts, `text/x-shellscript; charset="utf-8"` can be used as content type.

In order to create archive the `MultipartUserData` has to be instantiated. Than, user can add parts to multipart archive using `addPart`. The `MultipartBody` contains methods supporting creation of body parts.

If the very custom part is required, it can be created using `MultipartUserData.fromRawBody`, in this case full control over content type,
transfer encoding, and body properties is given to the user.

Below is an example for creating multipart user data with single body part responsible for installing `awscli` and configuring maximum size
of storage used by Docker containers:

```ts
const bootHookConf = ec2.UserData.forLinux();
bootHookConf.addCommands('cloud-init-per once docker_options echo \'OPTIONS="${OPTIONS} --storage-opt dm.basesize=40G"\' >> /etc/sysconfig/docker');

const setupCommands = ec2.UserData.forLinux();
setupCommands.addCommands('sudo yum install awscli && echo Packages installed らと > /var/tmp/setup');

const multipartUserData = new ec2.MultipartUserData();
// The docker has to be configured at early stage, so content type is overridden to boothook
multipartUserData.addPart(ec2.MultipartBody.fromUserData(bootHookConf, 'text/cloud-boothook; charset="us-ascii"'));
// Execute the rest of setup
multipartUserData.addPart(ec2.MultipartBody.fromUserData(setupCommands));

new ec2.LaunchTemplate(stack, '', {
userData: multipartUserData,
blockDevices: [
// Block device configuration rest
]
});
```

For more information see
[Specifying Multiple User Data Blocks Using a MIME Multi Part Archive](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/bootstrap_container_instance.html#multi-part_user_data)


## Importing existing subnet

To import an existing Subnet, call `Subnet.fromSubnetAttributes()` or
Expand Down

0 comments on commit 2715f0b

Please sign in to comment.