diff --git a/command/init.go b/command/init.go index 7b75bf263..ffc8de03b 100644 --- a/command/init.go +++ b/command/init.go @@ -206,6 +206,10 @@ func (c *InitCommand) Run(args []string) int { state = sMgr.State() } + if v := os.Getenv(ProviderSkipVerifyEnvVar); v != "" { + c.ignorePluginChecksum = true + } + // Now that we have loaded all modules, check the module tree for missing providers. err = c.getProviders(path, state, flagUpgrade) if err != nil { @@ -330,6 +334,9 @@ func (c *InitCommand) getProviders(path string, state *terraform.State, upgrade return err } digests[name] = digest + if c.ignorePluginChecksum { + digests[name] = nil + } } err = c.providerPluginsLock().Write(digests) if err != nil { diff --git a/command/meta.go b/command/meta.go index fb68b0601..84177ceef 100644 --- a/command/meta.go +++ b/command/meta.go @@ -51,9 +51,11 @@ type Meta struct { // pluginPath is a user defined set of directories to look for plugins. // This is set during init with the `-plugin-dir` flag, saved to a file in // the data directory. - // This overrides all other search paths when discoverying plugins. + // This overrides all other search paths when discovering plugins. pluginPath []string + ignorePluginChecksum bool + // Override certain behavior for tests within this package testingOverrides *testingOverrides @@ -224,6 +226,10 @@ func (m *Meta) StdinPiped() bool { return fi.Mode()&os.ModeNamedPipe != 0 } +const ( + ProviderSkipVerifyEnvVar = "TF_SKIP_PROVIDER_VERIFY" +) + // contextOpts returns the options to use to initialize a Terraform // context with the settings from this Meta. func (m *Meta) contextOpts() *terraform.ContextOpts { @@ -260,6 +266,9 @@ func (m *Meta) contextOpts() *terraform.ContextOpts { } opts.ProviderSHA256s = m.providerPluginsLock().Read() + if v := os.Getenv(ProviderSkipVerifyEnvVar); v != "" { + opts.SkipProviderVerify = true + } opts.Meta = &terraform.ContextMeta{ Env: m.Workspace(), diff --git a/terraform/context.go b/terraform/context.go index 649af3a7b..a814a85dd 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -65,7 +65,8 @@ type ContextOpts struct { // If non-nil, will apply as additional constraints on the provider // plugins that will be requested from the provider resolver. - ProviderSHA256s map[string][]byte + ProviderSHA256s map[string][]byte + SkipProviderVerify bool UIInput UIInput } @@ -185,7 +186,7 @@ func NewContext(opts *ContextOpts) (*Context, error) { var err error deps := ModuleTreeDependencies(opts.Module, state) reqd := deps.AllPluginRequirements() - if opts.ProviderSHA256s != nil { + if opts.ProviderSHA256s != nil && !opts.SkipProviderVerify { reqd.LockExecutables(opts.ProviderSHA256s) } providers, err = resourceProviderFactories(opts.ProviderResolver, reqd)