-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The generated kubeconfig is missing the region argument. This can lead to issues in many scenarios, e.g. when a user has `AWS_DEFAULT_REGION` set or when they have no default region set and use the provider configuration for setting the pulumi region (i.e. `aws:region`). This aligns the provider with how the AWS CLI generates the kubeconfig (`aws eks update-kubeconfig`). This change uses the cluster ARN to identify the cluster's region and sets it in the kubeconfig. The k8s provider's `kubeconfig` property will not trigger replacements. Multiple upgrade tests validate this (e.g. `aws-profile`). <!--Refer to related PRs or issues: #1234, or 'Fixes #1234' or 'Closes #1234'. Or link to full URLs to issues or pull requests in other GitHub repositories. -->
- Loading branch information
1 parent
b170816
commit a1061b6
Showing
3 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2016-2024, Pulumi Corporation. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import { getRegionFromArn } from "./utilities"; | ||
|
||
describe("getRegionFromArn", () => { | ||
test.each([ | ||
["arn:aws:eks:us-east-1:123456789012:cluster/my-awesome-cluster", "us-east-1"], | ||
["arn:aws:eks:us-west-2:123456789012:cluster/my-awesome-cluster", "us-west-2"], | ||
["arn:aws-cn:eks:cn-north-1:123456789012:cluster/my-awesome-cluster", "cn-north-1"], | ||
[ | ||
"arn:aws-us-gov:eks:us-gov-west-1:123456789012:cluster/my-awesome-cluster", | ||
"us-gov-west-1", | ||
], | ||
])("should extract the region from the ARN", (arn, expected) => { | ||
const region = getRegionFromArn(arn); | ||
expect(region).toEqual(expected); | ||
}); | ||
|
||
it("should throw an error for an ARN with less than 4 parts", () => { | ||
const arn = "arn:aws:service"; | ||
expect(() => getRegionFromArn(arn)).toThrow("Invalid ARN: 'arn:aws:service'"); | ||
}); | ||
|
||
it("should throw an error for an ARN not starting with 'arn'", () => { | ||
const arn = "invalid:aws:service:region:account-id:resource"; | ||
expect(() => getRegionFromArn(arn)).toThrow( | ||
"Invalid ARN: 'invalid:aws:service:region:account-id:resource'", | ||
); | ||
}); | ||
|
||
it("should throw an error for an empty ARN", () => { | ||
const arn = ""; | ||
expect(() => getRegionFromArn(arn)).toThrow("Invalid ARN: ''"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters