terraform-google-modules / terraform-google-cloud-nat

Creates and configures Cloud NAT
https://registry.terraform.io/modules/terraform-google-modules/cloud-nat/google
Apache License 2.0
80 stars 68 forks source link

feat(TPG >= 4.51)!: Support tcp_time_wait_timeout_sec #108

Closed dantheperson closed 1 year ago

dantheperson commented 1 year ago

Currently the module does not support setting this, the resource then defaults it to 120, and this overwrites any custom setting that has been set by a local-exec provisioner calling gcloud, or otherwise configured outside of terraform.

apeabody commented 1 year ago

/gcbrun

dantheperson commented 1 year ago

Thanks, not sure how I lost my change to actually apply the new var to the resource. Have updated minimum required provider too, it's quite a jump.

dantheperson commented 1 year ago

Regarding running the functional tests locally, is it known to work with personal GCP account, i.e. one with no organisation? I had a quick try but ran into a bunch of errors.

apeabody commented 1 year ago

/gcbrun

apeabody commented 1 year ago

Thanks, not sure how I lost my change to actually apply the new var to the resource. Have updated minimum required provider too, it's quite a jump.

Thanks - Yeah, it would be a breaking/major change regardless.

apeabody commented 1 year ago

Regarding running the functional tests locally, is it known to work with personal GCP account, i.e. one with no organisation? I had a quick try but ran into a bunch of errors.

The LINT tests should work with just make docker_lint, the full INT tests do require an organization: https://github.com/terraform-google-modules/terraform-google-cloud-nat/blob/master/CONTRIBUTING.md#integration-testing

apeabody commented 1 year ago

Thanks @dantheperson - Here is the INT output:

    subnetworks_test.go:45: 
            Error Trace:    /workspace/test/integration/subnetworks/subnetworks_test.go:45
                                        /builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/blueprint-test@v0.5.1/pkg/tft/terraform.go:408
                                        /builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/blueprint-test@v0.5.1/pkg/tft/terraform.go:428
                                        /builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/blueprint-test@v0.5.1/pkg/utils/stages.go:31
                                        /builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/blueprint-test@v0.5.1/pkg/tft/terraform.go:428
            Error:          Not equal: 
                            expected: map[string]interface {}{"enableEndpointIndependentMapping":true, "endpointTypes":[]interface {}{"ENDPOINT_TYPE_VM"}, "icmpIdleTimeoutSec":15, "minPortsPerVm":128, "name":"my-cloud-nat-cft-cloud-nat-test-RANDOM_ID", "natIpAllocateOption":"MANUAL_ONLY", "sourceSubnetworkIpRangesToNat":"LIST_OF_SUBNETWORKS", "subnetworks":[]interface {}{map[string]interface {}{"name":"https://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/us-east4/subnetworks/cft-cloud-nat-test-RANDOM_ID-a", "sourceIpRangesToNat":[]interface {}{"ALL_IP_RANGES"}}}, "tcpEstablishedIdleTimeoutSec":600, "tcpTimeWaitTimeoutSec":120, "tcpTransitoryIdleTimeoutSec":15, "udpIdleTimeoutSec":15}
                            actual  : map[string]interface {}{"enableEndpointIndependentMapping":true, "endpointTypes":[]interface {}{"ENDPOINT_TYPE_VM"}, "icmpIdleTimeoutSec":15, "minPortsPerVm":128, "name":"my-cloud-nat-cft-cloud-nat-test-RANDOM_ID", "natIpAllocateOption":"MANUAL_ONLY", "sourceSubnetworkIpRangesToNat":"LIST_OF_SUBNETWORKS", "subnetworks":[]interface {}{map[string]interface {}{"name":"https://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/us-east4/subnetworks/cft-cloud-nat-test-RANDOM_ID-a", "sourceIpRangesToNat":[]interface {}{"ALL_IP_RANGES"}}}, "tcpEstablishedIdleTimeoutSec":600, "tcpTimeWaitTimeoutSec":240, "tcpTransitoryIdleTimeoutSec":15, "udpIdleTimeoutSec":15}

                            Diff:
                            --- Expected
                            +++ Actual
                            @@ -19,3 +19,3 @@
                              (string) (len=28) "tcpEstablishedIdleTimeoutSec": (float64) 600,
                            - (string) (len=21) "tcpTimeWaitTimeoutSec": (float64) 120,
                            + (string) (len=21) "tcpTimeWaitTimeoutSec": (float64) 240,
                              (string) (len=27) "tcpTransitoryIdleTimeoutSec": (float64) 15,
            Test:           TestSubnetworks
apeabody commented 1 year ago

/gcbrun

dantheperson commented 1 year ago

It took me a long time to troubleshoot permissions, but i finally managed to run the integration tests locally. It might be worth adding a note CONTRIBUTING.md ?

To use this setup, you need a service account with Project Creator access on a folder and Billing Account User on the billing account

dantheperson commented 1 year ago

Actually no i did not run the test successfully. I successfully ran make docker_test_prepare

Now running make docker_test_integration it complains that kitchen.yaml doesn't exist, and indeed it doesn't

I think i will give up on running them locally now, it seems the tests are now passing on your build server.

Apply complete! Resources: 13 added, 0 changed, 0 destroyed.

Outputs:

project_id = "ci-cloud-nat-f617"
sa_key = <sensitive>
root@legski:/home/daniel/dev/terraform-google-cloud-nat# make docker_test_integration
docker run --rm -it \
    -e SERVICE_ACCOUNT_JSON \
    -v "/home/daniel/dev/terraform-google-cloud-nat":/workspace \
    gcr.io/cloud-foundation-cicd/cft/developer-tools:1.10 \
    /usr/local/bin/test_integration.sh
Activated service account credentials for: [gcp-terraform-provider-int-tes@dan-test-382622.iam.gserviceaccount.com]
Automatically setting inputs from outputs of test/setup
Activated service account credentials for: [ci-cloud-nat@ci-cloud-nat-f617.iam.gserviceaccount.com]
-----> Starting Test Kitchen (v2.7.2)
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::UserError
>>>>>> Message: Kitchen YAML file /workspace/kitchen.yml does not exist.
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

-----> Starting Test Kitchen (v2.7.2)
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::UserError
>>>>>> Message: Kitchen YAML file /workspace/kitchen.yml does not exist.
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

make: *** [Makefile:61: docker_test_integration] Error 20
apeabody commented 1 year ago

Actually no i did not run the test successfully. I successfully ran make docker_test_prepare

Now running make docker_test_integration it complains that kitchen.yaml doesn't exist, and indeed it doesn't

I think i will give up on running them locally now, it seems the tests are now passing on your build server.

Apply complete! Resources: 13 added, 0 changed, 0 destroyed.

Outputs:

project_id = "ci-cloud-nat-f617"
sa_key = <sensitive>
root@legski:/home/daniel/dev/terraform-google-cloud-nat# make docker_test_integration
docker run --rm -it \
  -e SERVICE_ACCOUNT_JSON \
  -v "/home/daniel/dev/terraform-google-cloud-nat":/workspace \
  gcr.io/cloud-foundation-cicd/cft/developer-tools:1.10 \
  /usr/local/bin/test_integration.sh
Activated service account credentials for: [gcp-terraform-provider-int-tes@dan-test-382622.iam.gserviceaccount.com]
Automatically setting inputs from outputs of test/setup
Activated service account credentials for: [ci-cloud-nat@ci-cloud-nat-f617.iam.gserviceaccount.com]
-----> Starting Test Kitchen (v2.7.2)
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::UserError
>>>>>> Message: Kitchen YAML file /workspace/kitchen.yml does not exist.
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

-----> Starting Test Kitchen (v2.7.2)
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::UserError
>>>>>> Message: Kitchen YAML file /workspace/kitchen.yml does not exist.
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

make: *** [Makefile:61: docker_test_integration] Error 20

Thanks @dantheperson - yes, all the tests passed on the CI.