hashicorp / terraform-cdk

Define infrastructure resources using programming constructs and provision them using HashiCorp Terraform
https://www.terraform.io/cdktf
Mozilla Public License 2.0
4.83k stars 449 forks source link

S3Backend | Missing skip_region_validation property #2049

Closed nlucansk closed 2 years ago

nlucansk commented 2 years ago

Community Note

cdktf & Language Versions

cdktf | 0.12.1 py | 3.10.6

Affected Resource(s)

cdktf | S3Backend

Debug Output

Without skip_region_validation

✖  cdktf diff
infrastructure  Initializing the backend...

⠇  Processing
[2022-08-24T16:00:20.632] [ERROR] default - ╷
│ Error: Invalid AWS Region: pl-waw
│
│
╵
infrastructure  ╷                                                                                                                                                         
                │ Error: Invalid AWS Region: pl-waw                                                                                                                       
                │
                │
                ╵

"With" skip_region_validation

✖  cdktf diff

⠇  Synthesizing
[2022-08-24T16:11:26.536] [ERROR] default - Traceback (most recent call last):
  File "/home/nlucansk/private/home-automation/infrastructure/main.py", line 23, in <module>
    MyStack(app, "infrastructure")
  File "/home/nlucansk/.local/share/virtualenvs/infrastructure-IPIz07jp/lib/python3.10/site-packages/jsii/_runtime.py", line 86, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/home/nlucansk/private/home-automation/infrastructure/main.py", line 11, in __init__
    backend = S3Backend(
  File "/home/nlucansk/.local/share/virtualenvs/infrastructure-IPIz07jp/lib/python3.10/site-packages/jsii/_runtime.py", line 86, in __call__
    inst = super().__call__(*args, **kwargs)
cdktf encountered an error while synthesizing

Synth command: pipenv run python main.py
Error:         non-zero exit code 1

Command output on stderr:

    Traceback (most recent call last):
      File "/home/nlucansk/private/home-automation/infrastructure/main.py", line 23, in <module>
        MyStack(app, "infrastructure")
      File "/home/nlucansk/.local/share/virtualenvs/infrastructure-IPIz07jp/lib/python3.10/site-packages/jsii/_runtime.py", line 86, in __call__
        inst = super().__call__(*args, **kwargs)
      File "/home/nlucansk/private/home-automation/infrastructure/main.py", line 11, in __init__
        backend = S3Backend(
      File "/home/nlucansk/.local/share/virtualenvs/infrastructure-IPIz07jp/lib/python3.10/site-packages/jsii/_runtime.py", line 86, in __call__
        inst = super().__call__(*args, **kwargs)
    TypeError: S3Backend.__init__() got an unexpected keyword argument 'skip_region_validation'

Expected Behavior

S3Backend should have skip_region_validation property

Actual Behavior

S3Backend is missing skip_region_validation property

Steps to Reproduce

Use any "non AWS S3 bucket" ( I am using Scaleway )

from constructs import Construct
from cdktf import App, TerraformStack, S3Backend

class MyStack(TerraformStack):
    def __init__(self, scope: Construct, ns: str):
        super().__init__(scope, ns)

        # define resources here
        backend = S3Backend(
            self,
            bucket="examplebucket",
            key="test.tfstate",
            endpoint="https://s3.pl-waw.scw.cloud",
            region="pl-waw",
            skip_credentials_validation=True,
            skip_region_validation=True  <-- Missing
        )

app = App()
MyStack(app, "infrastructure")
app.synth()

Important Factoids

https://www.terraform.io/language/settings/backends/s3#skip_region_validation Not visible on : https://constructs.dev/packages/cdktf/v/0.12.1/api/S3Backend?lang=python

image

References

ansgarm commented 2 years ago

Thank you for reporting this @nlucansk 👍 I added a PR to fix this: #2050

Until this gets shipped you should be able to use an escape hatch as a workaround:

backend = S3Backend(
  self,
  bucket="examplebucket",
  key="test.tfstate",
  endpoint="https://s3.pl-waw.scw.cloud",
  region="pl-waw",
  skip_credentials_validation=True,
)

backend.add_override("skip_region_validation", False)
nlucansk commented 2 years ago

Thank you @ansgarm, Works with WA

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.