title: How do I provide a region when deleting AWS IAM Access Analyzers with the Go SDK V2?
body: <p>I am trying to delete an IAM Access Analyzer using V2 of the Go SDK, but I keep getting the following issue:</p>
  <blockquote>
  <p>failed to call service: AccessAnalyzer, operation: DeleteAnalyzer, error: failed to resolve service endpoint, an AWS region is required, but was not found</p>
  </blockquote>
  <p>I am not having issues using the SDK for resources under other services. My code is as follows, with the region set by env variables as per <a href="https://aws.github.io/aws-sdk-go-v2/docs/configuring-sdk/#specifying-the-aws-region" rel="nofollow noreferrer">this documentation</a>:</p>
  <pre><code>        name := &quot;myanalyzer&quot;
      cfg, err := config.LoadDefaultConfig(context.TODO(),
          config.WithSharedConfigProfile(profile),
          config.WithRegion(&quot;eu-west-1&quot;),
      )
  
      if err != nil {
          log.Fatalln(&quot;Error loading configuration&quot;, err)
      }
          resolver := accessanalyzer.NewDefaultEndpointResolver()
  
      client := accessanalyzer.NewFromConfig(cfg, func(o *accessanalyzer.Options) {
          o.Region = &quot;eu-west-1&quot;
          o.EndpointOptions = options
          o.EndpointResolver = resolver
      })
  
      input := &amp;accessanalyzer.DeleteAnalyzerInput{
          AnalyzerName: &amp;name,
      }
      
      result, err := client.DeleteAnalyzer(context.TODO(), input)
  </code></pre>
  <p>I have also tried to specify a resolver URL:</p>
  <pre><code>        name := &quot;myanalyzer&quot;
      cfg, err := config.LoadDefaultConfig(context.TODO(),
          config.WithSharedConfigProfile(profile),
          config.WithRegion(&quot;eu-west-1&quot;),
      )
  
      if err != nil {
          log.Fatalln(&quot;Error loading configuration&quot;, err)
      }
          resolver := accessanalyzer.EndpointResolverFromURL(&quot;https://access-analyzer.eu-west-1.amazonaws.com&quot;)
  
      client := accessanalyzer.NewFromConfig(cfg, func(o *accessanalyzer.Options) {
          o.Region = &quot;eu-west-1&quot;
          o.EndpointOptions = options
          o.EndpointResolver = resolver
      })
  
      input := &amp;accessanalyzer.DeleteAnalyzerInput{
          AnalyzerName: &amp;name,
      }
      
      result, err := client.DeleteAnalyzer(context.TODO(), input)
  </code></pre>
  <p>This does not work either, returning an error of</p>
  <blockquote>
  <p>requestID: 85f3d4ca-dc1b-43a4-9272-a05adea0f9d7, error: api error InvalidSignatureException: Credential should be scoped to a valid region, not ''.</p>
  </blockquote>
  <p>How can I provide the region so that the analyzer can be deleted? Any help would be much appreciated.</p>
  <p>AWS SDK Go version: 1.5.0,
  Go version: 1.16.3 linux/amd64</p>