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

Add parameter for skipping default security groups #1416

Merged
merged 11 commits into from
Oct 3, 2024

Conversation

flostadler
Copy link
Contributor

@flostadler flostadler commented Oct 2, 2024

Pulumi EKS currently always creates a cluster security group and node security group.

  • The cluster security group gets assigned to the control plane ENIs in addition to the security group EKS creates (see AWS Docs). This security group gets an ingress rule from the node security group.
  • The node security group gets assigned to NodeGroup and NodeGroupV2 components that do not specify a custom security group.

Users that either manage the node security themselves or use the ManagedNodeGroup component (uses the EKS created SG) do not need those default security groups.

This change adds a flag on the cluster (skipDefaultSecurityGroups) that will skip creating those default security groups. Instead.

This introduces a small breaking change, the clusterSecurityGroup, nodeSecurityGroup and clusterIngressRule outputs are now optional. The impact of this should be minimal because users that create custom node groups usually do not use the security groups of the cluster for that. If they do, they need to add a null check.

Fixes #747

@flostadler flostadler added the needs-release/major Marking a PR to compute the next major version label Oct 2, 2024
@flostadler flostadler requested review from t0yv0, corymhall and a team October 2, 2024 20:12
@flostadler flostadler self-assigned this Oct 2, 2024
Copy link

github-actions bot commented Oct 2, 2024

Does the PR have any schema changes?

Found 4 breaking changes:

Resources

  • "eks:index:Cluster": required:
    • 🟢 "clusterSecurityGroup" property is no longer Required
    • 🟢 "eksClusterIngressRule" property is no longer Required
    • 🟢 "nodeSecurityGroup" property is no longer Required

Types

  • 🟢 "eks:index:CoreData": required: "clusterSecurityGroup" property is no longer Required
    No new resources/functions.

@flostadler flostadler force-pushed the flostadler/skip-default-security-groups branch from 1061126 to 7955f51 Compare October 3, 2024 10:26
.all([coreSecurityGroupId, args.nodeSecurityGroup?.id, core.nodeSecurityGroupTags])
.apply(([coreSecurityGroup, nodeSecurityGroup, sgTags]) => {
if (coreSecurityGroup && nodeSecurityGroup) {
if (sgTags && coreSecurityGroup !== nodeSecurityGroup) {
Copy link
Member

Choose a reason for hiding this comment

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

Always suspicious of equality but this look like it's over string right? Might be OK. Perhaps call the variables "coreSecurityGroupId" or some such.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it's over string. Noticed that it was comparing Output<string> before..

// apply the tags to the cluster security group if it was created by EKS
if (!eksClusterSecurityGroup) {
const eksCreatedSgId = eksCluster.vpcConfig.clusterSecurityGroupId;
eksClusterSecurityGroup = aws.ec2.SecurityGroup.get(
Copy link
Member

Choose a reason for hiding this comment

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

Does this .get work OK for you inlight of today's discussion about a possible bug in MLC R.Get ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this was before our call. I just pushed a new version

nodejs/eks/cluster.ts Outdated Show resolved Hide resolved
/// See for more details: https://docs.aws.amazon.com/eks/latest/userguide/sec-group-reqs.html.
/// </summary>
[Input("skipDefaultSecurityGroups")]
public bool? SkipDefaultSecurityGroups { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

Weird three-state boolean. true, false, and unknown. Alas, not worth fixing probably.

)

// should return the EKS created security group instead of the default one the provider would create
assert.Equal(t, info.Outputs["eksCreatedSgMng"], info.Outputs["clusterSecurityGroupMng"])
Copy link
Member

Choose a reason for hiding this comment

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

Nice

@flostadler flostadler marked this pull request as draft October 3, 2024 16:08
@flostadler flostadler force-pushed the flostadler/skip-default-security-groups branch from 7955f51 to 6e9f619 Compare October 3, 2024 16:28
@@ -17,7 +17,7 @@ export function createNodeGroup(
return new eks.NodeGroup(name, {
cluster: args.cluster,
nodeSecurityGroup: args.cluster.nodeSecurityGroup,
clusterIngressRule: args.cluster.eksClusterIngressRule,
clusterIngressRule: args.cluster.eksClusterIngressRule.apply(rule => rule!),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's the small breaking change

.all([coreSecurityGroupId, args.nodeSecurityGroup?.id, core.nodeSecurityGroupTags])
.apply(([coreSecurityGroup, nodeSecurityGroup, sgTags]) => {
if (coreSecurityGroup && nodeSecurityGroup) {
if (sgTags && coreSecurityGroup !== nodeSecurityGroup) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it's over string. Noticed that it was comparing Output<string> before..

nodejs/eks/cluster.ts Outdated Show resolved Hide resolved
@flostadler flostadler marked this pull request as ready for review October 3, 2024 16:37
@flostadler
Copy link
Contributor Author

@t0yv0 @corymhall can you please have another look? I had to change the approach due to the issues with .get in MLCs.

@t0yv0
Copy link
Member

t0yv0 commented Oct 3, 2024

I had to change the approach due to the issues with .get in MLCs.

Very much worth spending time on to extract a repro and link here 🙏 If you are out of capacity sent it over to me as I might have some bandwidth.

@flostadler
Copy link
Contributor Author

flostadler commented Oct 3, 2024

I had to change the approach due to the issues with .get in MLCs.

Very much worth spending time on to extract a repro and link here 🙏 If you are out of capacity sent it over to me as I might have some bandwidth.

Fully agreed! I already had a chat with Will about this. I'll try to create a minimal repro tomorrow to further investigate

@flostadler flostadler merged commit 62a8eca into release-3.x.x Oct 3, 2024
34 checks passed
@flostadler flostadler deleted the flostadler/skip-default-security-groups branch October 3, 2024 20:15
flostadler added a commit that referenced this pull request Oct 17, 2024
Pulumi EKS currently always creates a cluster security group and node
security group.
- The cluster security group gets assigned to the control plane ENIs in
addition to the security group EKS creates (see [AWS
Docs](https://docs.aws.amazon.com/eks/latest/userguide/sec-group-reqs.html)).
This security group gets an ingress rule from the node security group.
- The node security group gets assigned to `NodeGroup` and `NodeGroupV2`
components that do not specify a custom security group.

Users that either manage the node security themselves or use the
`ManagedNodeGroup` component (uses the EKS created SG) do not need those
default security groups.

This change adds a flag on the cluster (`skipDefaultSecurityGroups`)
that will skip creating those default security groups. Instead.

This introduces a small breaking change, the `clusterSecurityGroup`,
`nodeSecurityGroup` and `clusterIngressRule` outputs are now optional.
The impact of this should be minimal because users that create custom
node groups usually do not use the security groups of the cluster for
that. If they do, they need to add a null check.

Fixes #747
flostadler added a commit that referenced this pull request Oct 17, 2024
Pulumi EKS currently always creates a cluster security group and node
security group.
- The cluster security group gets assigned to the control plane ENIs in
addition to the security group EKS creates (see [AWS
Docs](https://docs.aws.amazon.com/eks/latest/userguide/sec-group-reqs.html)).
This security group gets an ingress rule from the node security group.
- The node security group gets assigned to `NodeGroup` and `NodeGroupV2`
components that do not specify a custom security group.

Users that either manage the node security themselves or use the
`ManagedNodeGroup` component (uses the EKS created SG) do not need those
default security groups.

This change adds a flag on the cluster (`skipDefaultSecurityGroups`)
that will skip creating those default security groups. Instead.

This introduces a small breaking change, the `clusterSecurityGroup`,
`nodeSecurityGroup` and `clusterIngressRule` outputs are now optional.
The impact of this should be minimal because users that create custom
node groups usually do not use the security groups of the cluster for
that. If they do, they need to add a null check.

Fixes #747
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-release/major Marking a PR to compute the next major version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants