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

Disable slow Plugin Framework Config validation #2920

Merged
merged 7 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/pulumi/pulumi-aws/examples/v6

go 1.21
go 1.21.0

require (
github.com/aws/aws-sdk-go v1.45.24
Expand Down
2 changes: 2 additions & 0 deletions examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2320,6 +2320,8 @@ github.com/prometheus/prometheus v0.37.0/go.mod h1:egARUgz+K93zwqsVIAneFlLZefyGO
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/pulumi/esc v0.5.6 h1:4WV3X7OEVcChIwbSG+JxhZDdmq/q7lFPaSjHRYlPwmI=
github.com/pulumi/esc v0.5.6/go.mod h1:wpwNfVS5fV7Kd51j4dJ6FWYlKfxdqyppgp0gtkzqH04=
github.com/pulumi/providertest v0.0.2 h1:XtnO603irWnSgfIbz6OK8hffIJ0GIrKRl3tYMJwI1H8=
github.com/pulumi/providertest v0.0.2/go.mod h1:kZYBA14iemv3X4G4xsBKaa72zVbn//IyL5HTYKpLuy0=
github.com/pulumi/pulumi-terraform-bridge/pf v0.18.2 h1:lSm5nbZETkeVNJQTcGOmuHCSXPhDj72dFC2Wan08Wpg=
github.com/pulumi/pulumi-terraform-bridge/pf v0.18.2/go.mod h1:4ii0lFkIQMhCZg5du0xEtAB36Kk0WuLtDVO/ntTxRIs=
github.com/pulumi/pulumi-terraform-bridge/testing v0.0.2-0.20230927165309-e3fd9503f2d3 h1:bBWWeAtSPPYpKYlPZr2h0BiYgWQpHRIk0HO/MQmB+jc=
Expand Down
137 changes: 137 additions & 0 deletions provider/configure_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
// Copyright 2016-2023, 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.

package provider

import (
"context"
"strings"
"testing"
"time"

testutils "github.com/pulumi/providertest/replay"
pfbridge "github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge"
"github.com/stretchr/testify/require"

version "github.com/pulumi/pulumi-aws/provider/v6/pkg/version"
)

func TestCheckConfigWithUnknownKeys(t *testing.T) {
replaySequence(t, strings.ReplaceAll(`
[{
"method": "/pulumirpc.ResourceProvider/CheckConfig",
"request": {
"urn": "urn:pulumi:dev::aws-2880::pulumi:providers:aws::default_6_5_0",
"olds": {},
"news": {
"unknownKey": "injected",
"accessKey": "test",
"region": "us-east-1",
"s3UsePathStyle": "true",
"secretKey": "test",
"skipCredentialsValidation": "true",
"skipRequestingAccountId": "true",
"version": "6.5.0"
}
},
"response": {
"inputs": "*",
"failures": [{"reason": "could not validate provider configuration: Invalid or unknown key. Check '''pulumi config get aws:unknownKey'''."}]
}
}]`, "'''", "`"))
}

func TestCheckConfigRunsUpstreamValidators(t *testing.T) {
replaySequence(t, strings.ReplaceAll(`
[{
"method": "/pulumirpc.ResourceProvider/CheckConfig",
"request": {
"urn": "urn:pulumi:dev::aws-2880::pulumi:providers:aws::default_6_5_0",
"olds": {},
"news": {
"assumeRoleWithWebIdentity": {"roleArn": "INVALID-ARN", "webIdentityToken": "TOKEN"},
"accessKey": "test",
"region": "us-east-1",
"s3UsePathStyle": "true",
"secretKey": "test",
"skipCredentialsValidation": "true",
"skipRequestingAccountId": "true",
"version": "6.5.0"
}
},
"response": {
"inputs": "*",
"failures": [
{"reason": "could not validate provider configuration: \"assume_role_with_web_identity.0.role_arn\" (INVALID-ARN) is an invalid ARN: arn: invalid prefix. Check '''pulumi config get --path aws:assumeRoleWithWebIdentity.roleArn'''."}
]
}
}]`, "'''", "`"))
}

func TestCheckConfigFastWithCustomEndpoints(t *testing.T) {
time0 := time.Now()
replaySequence(t, `
[{
"method": "/pulumirpc.ResourceProvider/CheckConfig",
"request": {
"urn": "urn:pulumi:dev::aws-2880::pulumi:providers:aws::default_6_5_0",
"olds": {},
"news": {
"accessKey": "test",
"endpoints": "[{\"accessanalyzer\":\"http://localhost:4566\"},{\"account\":\"http://localhost:4566\"},{\"acm\":\"http://localhost:4566\"},{\"acmpca\":\"http://localhost:4566\"},{\"amg\":\"http://localhost:4566\"},{\"amp\":\"http://localhost:4566\"},{\"amplify\":\"http://localhost:4566\"},{\"apigateway\":\"http://localhost:4566\"},{\"apigatewayv2\":\"http://localhost:4566\"},{\"appautoscaling\":\"http://localhost:4566\"},{\"appconfig\":\"http://localhost:4566\"},{\"appflow\":\"http://localhost:4566\"}]",
"region": "us-east-1",
"s3UsePathStyle": "true",
"secretKey": "test",
"skipCredentialsValidation": "true",
"skipRequestingAccountId": "true",
"version": "6.5.0"
}
},
"response": {
"inputs": {
"accessKey": "test",
"endpoints": "[{\"accessanalyzer\":\"http://localhost:4566\"},{\"account\":\"http://localhost:4566\"},{\"acm\":\"http://localhost:4566\"},{\"acmpca\":\"http://localhost:4566\"},{\"amg\":\"http://localhost:4566\"},{\"amp\":\"http://localhost:4566\"},{\"amplify\":\"http://localhost:4566\"},{\"apigateway\":\"http://localhost:4566\"},{\"apigatewayv2\":\"http://localhost:4566\"},{\"appautoscaling\":\"http://localhost:4566\"},{\"appconfig\":\"http://localhost:4566\"},{\"appflow\":\"http://localhost:4566\"}]",
"region": "us-east-1",
"s3UsePathStyle": "true",
"secretKey": "test",
"skipCredentialsValidation": "true",
"skipMetadataApiCheck": "true",
"skipRegionValidation": "true",
"skipRequestingAccountId": "true",
"version": "6.5.0"
}
}
}]`)
cutoff := 5 * time.Second
require.Truef(t, time0.Add(cutoff).After(time.Now()), "CheckConfig with custom endpoints is taking more than %v", cutoff)
}

func replaySequence(t *testing.T, sequence string) {
info := *Provider()
ctx := context.Background()
p, err := pfbridge.MakeMuxedServer(ctx, info.Name, info,
/*
* We leave the schema blank. This will result in incorrect calls to
* GetSchema, but otherwise does not effect the provider. It reduces the
* time to test start by minutes.
*/
[]byte("{}"),
)(nil)
require.NoError(t, err)
testutils.ReplaySequence(t, p, sequence)
}

func init() {
version.Version = "6.0.0"
}
3 changes: 2 additions & 1 deletion provider/go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
module github.com/pulumi/pulumi-aws/provider/v6

go 1.21
go 1.21.0

require (
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.12
github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.37
github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0
github.com/hashicorp/terraform-provider-aws v1.60.1-0.20220923175450-ca71523cdc36
github.com/mitchellh/go-homedir v1.1.0
github.com/pulumi/providertest v0.0.2
github.com/pulumi/pulumi-terraform-bridge/pf v0.18.2
github.com/pulumi/pulumi-terraform-bridge/v3 v3.63.1
github.com/pulumi/pulumi/pkg/v3 v3.90.1
Expand Down
2 changes: 2 additions & 0 deletions provider/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2340,6 +2340,8 @@ github.com/prometheus/prometheus v0.37.0/go.mod h1:egARUgz+K93zwqsVIAneFlLZefyGO
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/pulumi/esc v0.5.6 h1:4WV3X7OEVcChIwbSG+JxhZDdmq/q7lFPaSjHRYlPwmI=
github.com/pulumi/esc v0.5.6/go.mod h1:wpwNfVS5fV7Kd51j4dJ6FWYlKfxdqyppgp0gtkzqH04=
github.com/pulumi/providertest v0.0.2 h1:XtnO603irWnSgfIbz6OK8hffIJ0GIrKRl3tYMJwI1H8=
github.com/pulumi/providertest v0.0.2/go.mod h1:kZYBA14iemv3X4G4xsBKaa72zVbn//IyL5HTYKpLuy0=
github.com/pulumi/pulumi-java/pkg v0.9.8 h1:c8mYsalnRXA2Ibgvv6scefOn6mW1Vb0UT0mcDqjsivQ=
github.com/pulumi/pulumi-java/pkg v0.9.8/go.mod h1:c6rSw/+q4O0IImgJ9axxoC6QesbPYWBaG5gimbHouUQ=
github.com/pulumi/pulumi-terraform-bridge/pf v0.18.2 h1:lSm5nbZETkeVNJQTcGOmuHCSXPhDj72dFC2Wan08Wpg=
Expand Down
3 changes: 3 additions & 0 deletions provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,9 @@ func Provider() *tfbridge.ProviderInfo {
UpstreamRepoPath: "./upstream",
DocRules: &tfbridge.DocRuleInfo{EditRules: editRules},

// See pulumi/pulumi-aws#2880
SkipValidateProviderConfigForPluginFramework: true,
Copy link
Member

Choose a reason for hiding this comment

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

I didn't know this was in the bridge.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was added to address this P1 specifically.

Copy link
Member

Choose a reason for hiding this comment

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

I figured 😄


MetadataInfo: tfbridge.NewProviderMetadata(metadata),

Config: map[string]*tfbridge.SchemaInfo{
Expand Down
Loading