Skip to content

Conversation

@isker
Copy link
Contributor

@isker isker commented May 29, 2025

https://aws.amazon.com/about-aws/whats-new/2025/04/aws-codebuild-ec2-instance-type-configurable-storage-size/

CodeBuild now supports specifying specific EC2 instance types to serve as fleet compute.

Add this support to the Fleet construct by way of adding CUSTOM_INSTANCE_TYPE to the FleetComputeType enum, and instanceType to ComputeConfiguration.

Also, add VPC support to Fleet. This mirrors the VPC support in Project. When using Fleets, the VPC configured on the Project is disallowed by CloudFormation. Only the VPC on the Fleet applies. VPC support required adding a Role to the Fleet to handle provisioning EC2 network interfaces in the configured VPC.

Describe any new or updated permissions being added

When configuring a VPC on a Fleet, IAM permissions are granted to a CodeBuild Role as described here.

Description of how you validated changes

Unit and integration tests.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team May 29, 2025 01:13
@github-actions github-actions bot added p2 repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK labels May 29, 2025
Comment on lines +40 to +44
// Incredibly, if you pass a SubnetSelection that produces more than 1
// subnet, you currently get this error:
// > Resource handler returned message: "Invalid vpc config: the maximum number of subnets is 1
// This seems like a terrible limitation from the CodeBuild team.
// maxAzs: 2,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is bad. If anyone at AWS can talk to the CodeBuild team... I've never seen another service that demands a single subnet like this. The CloudFormation types claim you can use "up to 16" but anything more than 1 fails at deploy time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ozelalisen maybe you can forward this complaint internally 🥲.

Copy link
Member

Choose a reason for hiding this comment

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

Will follow up on this

@isker isker force-pushed the codebuild-fleet-custom-instance-type-vpc branch from 28828ff to d7ab2f0 Compare May 29, 2025 02:13
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label May 29, 2025
@isker isker force-pushed the codebuild-fleet-custom-instance-type-vpc branch 3 times, most recently from 8256ca3 to 3a75586 Compare June 12, 2025 03:47
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jun 14, 2025
@isker
Copy link
Contributor Author

isker commented Jun 14, 2025

@alvazjor why did main get force pushed here? Every PR now has many conflicts that are challenging to resolve :(.

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@isker isker force-pushed the codebuild-fleet-custom-instance-type-vpc branch from 3a75586 to b26bef7 Compare June 16, 2025 00:51
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: b26bef7
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jun 16, 2025
Copy link
Contributor

@badmintoncryer badmintoncryer left a comment

Choose a reason for hiding this comment

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

Thank you for your work! I've added some minor comments.

Is there a reason for combining the two features - VPC and Instance Type support - into a single PR? I feel these should typically be split into one feature per PR.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Aug 20, 2025
@isker
Copy link
Contributor Author

isker commented Aug 20, 2025

Thank you for your work! I've added some minor comments.

Thank you very much for reviewing.

Is there a reason for combining the two features - VPC and Instance Type support - into a single PR? I feel these should typically be split into one feature per PR.

The reason I've combined them is that I want to use both of these features myself. I do not think they strictly depend on one another, but because they modify code in the same place, if I were to split them up, whichever branch merged first would conflict with the other. So, it was easier for me to develop them together. So, I hope this it's okay to do it like this.

@isker isker force-pushed the codebuild-fleet-custom-instance-type-vpc branch from b26bef7 to 2966716 Compare August 21, 2025 04:20
@isker
Copy link
Contributor Author

isker commented Aug 21, 2025

I have rebased and am rerunning the new integration tests in this PR, as main has changed the snapshots. It takes a really long time to run integration tests that involve fleets, because fleet instances must exist for at least an hour before they can be deleted. I will hopefully finish it tomorrow and then will push the fixed tests.

@isker isker force-pushed the codebuild-fleet-custom-instance-type-vpc branch from 2966716 to 99d2d1e Compare August 21, 2025 13:33
@isker
Copy link
Contributor Author

isker commented Aug 21, 2025

😕 the main build succeeds but I don't understand either of the other jobs that failed. Especially the security guardian one, seems all unrelated to my changes.

@isker isker requested a review from badmintoncryer August 22, 2025 02:06
Copy link
Contributor

@badmintoncryer badmintoncryer left a comment

Choose a reason for hiding this comment

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

Thank you for the thorough deployment verification. As noted in the comments, while there is a discrepancy between the documentation and the IAM policy, I understand that the implementation is correct.

Since large PRs tend to get deprioritized for review, I think it would be better for both of us to limit future PRs to a single feature.

@badmintoncryer
Copy link
Contributor

badmintoncryer commented Aug 22, 2025

I don't think you need to worry much about CI processes like Security Guardian, as they are flaky and their failures don't affect the review status.
Also, due to a separate issue, the needs-maintainer-review label is currently not being attached. Please wait while we address this.

#35268

@isker
Copy link
Contributor Author

isker commented Aug 27, 2025

@badmintoncryer do you know how to get the label added now that #35268 is fixed?

@badmintoncryer
Copy link
Contributor

@isker Normally, this issue should have been resolved by merging the main branch, but it seems it has not been fixed yet.

@isker isker force-pushed the codebuild-fleet-custom-instance-type-vpc branch from 99d2d1e to 8e64358 Compare August 29, 2025 21:14
@isker
Copy link
Contributor Author

isker commented Aug 29, 2025

Still no label 🥲.

@isker
Copy link
Contributor Author

isker commented Aug 29, 2025

it seems it has not been fixed yet.

@badmintoncryer is there an open issue for this?

@isker isker force-pushed the codebuild-fleet-custom-instance-type-vpc branch from 8e64358 to 6214d0b Compare September 3, 2025 04:21
@alvazjor alvazjor added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 3, 2025
@ozelalisen ozelalisen self-assigned this Sep 9, 2025
@isker
Copy link
Contributor Author

isker commented Sep 24, 2025

Hi @ozelalisen, I see you assigned yourself a while ago. I would be grateful for a review.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 25, 2025
@isker isker force-pushed the codebuild-fleet-custom-instance-type-vpc branch from 6214d0b to 03a3894 Compare September 25, 2025 21:53
@mergify mergify bot dismissed ozelalisen’s stale review September 25, 2025 21:53

Pull request has been modified.

@isker isker force-pushed the codebuild-fleet-custom-instance-type-vpc branch 2 times, most recently from 92dfd15 to 39ec36e Compare September 26, 2025 03:13
@isker isker requested a review from ozelalisen September 26, 2025 03:17
@isker
Copy link
Contributor Author

isker commented Sep 29, 2025

@ozelalisen I think I've addressed everything, please take another look.

@ozelalisen ozelalisen added the pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes. label Sep 30, 2025
@ozelalisen
Copy link
Member

@isker There are some merge conflicts, once you resolve them, I'll approve the PR

https://aws.amazon.com/about-aws/whats-new/2025/04/aws-codebuild-ec2-instance-type-configurable-storage-size/

CodeBuild now supports specifying specific EC2 instance types to serve
as fleet compute.

Add this support to the Fleet construct by way of adding
CUSTOM_INSTANCE_TYPE to the FleetComputeType enum, and `instanceType` to
`ComputeConfiguration`.

Also, add VPC support to Fleet. This mirrors the VPC support in Project.
When using Fleets, the VPC configured on the Project does nothing. Only
the VPC on the Fleet applies. This required adding a Role to the Fleet
to handle provisioning EC2 network interfaces in the configured VPC.
@isker isker force-pushed the codebuild-fleet-custom-instance-type-vpc branch from 39ec36e to aa23ae8 Compare September 30, 2025 16:19
Copy link
Member

@ozelalisen ozelalisen left a comment

Choose a reason for hiding this comment

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

Thank you for this PR, LGTM, just left minor comment regarding permissions for future reference

Comment on lines +485 to +487
'ec2:CreateNetworkInterface',
'ec2:DeleteNetworkInterface',
'ec2:ModifyNetworkInterfaceAttribute',
Copy link
Member

Choose a reason for hiding this comment

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

The IAM permissions in this PR appear to be correct and align with AWS CodeBuild's official documentation. I also encountered deployment errors related to The service role is not authorized to perform ec2:CreateNetworkInterface when scoping down to subnetArns. Given this limitation, it is okay to merge this PR

Comment on lines +40 to +44
// Incredibly, if you pass a SubnetSelection that produces more than 1
// subnet, you currently get this error:
// > Resource handler returned message: "Invalid vpc config: the maximum number of subnets is 1
// This seems like a terrible limitation from the CodeBuild team.
// maxAzs: 2,
Copy link
Member

Choose a reason for hiding this comment

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

Will follow up on this

@ozelalisen ozelalisen merged commit 5c2781b into aws:main Sep 30, 2025
20 checks passed
@github-actions
Copy link
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

p2 pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes. repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants