http (Data Source)

The http data source makes an HTTP GET request to the given URL and exports information about the response.

The given URL may be either an http or https URL. This resource will issue a warning if the result is not UTF-8 encoded.

By default, there are no retries. Configuring the retry block will result in retries if an error is returned by the client (e.g., connection errors) or if a 5xx-range (except 501) status code is received. For further details see go-retryablehttp.

Example Usage

# DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug
from constructs import Construct
from cdktf import TerraformStack
#
# Provider bindings are generated by running `cdktf get`.
# See https://cdk.tf/provider-generation for more details.
#
from imports.http. import DataHttp
class MyConvertedCode(TerraformStack):
    def __init__(self, scope, name):
        super().__init__(scope, name)
        DataHttp(self, "example",
            request_headers=[{
                "Accept": "application/json"
            }
            ],
            url="https://checkpoint-api.hashicorp.com/v1/check/terraform"
        )
        DataHttp(self, "example_head",
            method="HEAD",
            url="https://checkpoint-api.hashicorp.com/v1/check/terraform"
        )
        DataHttp(self, "example_post",
            method="POST",
            request_body="request body",
            url="https://checkpoint-api.hashicorp.com/v1/check/terraform"
        )

Usage with Postcondition

Precondition and Postcondition checks are available with Terraform v1.2.0 and later.

# DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug
from constructs import Construct
from cdktf import TerraformSelf, Fn, TerraformStack
#
# Provider bindings are generated by running `cdktf get`.
# See https://cdk.tf/provider-generation for more details.
#
from imports.http. import DataHttp
class MyConvertedCode(TerraformStack):
    def __init__(self, scope, name):
        super().__init__(scope, name)
        DataHttp(self, "example",
            lifecycle={
                "postcondition": [{
                    "condition": Fn.contains([201, 204],
                    TerraformSelf.get_any("status_code")),
                    "error_message": "Status code invalid"
                }
                ]
            },
            request_headers=[{
                "Accept": "application/json"
            }
            ],
            url="https://checkpoint-api.hashicorp.com/v1/check/terraform"
        )

Usage with Precondition

Precondition and Postcondition checks are available with Terraform v1.2.0 and later.

# DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug
from cdktf import TerraformResourceLifecycle, Precondition
from constructs import Construct
from cdktf import Fn, TerraformStack
#
# Provider bindings are generated by running `cdktf get`.
# See https://cdk.tf/provider-generation for more details.
#
from imports.http. import DataHttp
from imports.random.uuid import Uuid
class MyConvertedCode(TerraformStack):
    def __init__(self, scope, name):
        super().__init__(scope, name)
        data_http_example = DataHttp(self, "example",
            request_headers=[{
                "Accept": "application/json"
            }
            ],
            url="https://checkpoint-api.hashicorp.com/v1/check/terraform"
        )
        random_uuid_example = Uuid(self, "example_1",
            lifecycle=TerraformResourceLifecycle(
                precondition=[Precondition(
                    condition=Fn.contains([201, 204], data_http_example.status_code),
                    error_message="Status code invalid"
                )
                ]
            )
        )
        # This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.
        random_uuid_example.override_logical_id("example")

Usage with Provisioner

Failure Behaviour can be leveraged within a provisioner in order to raise an error and stop applying.

# DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug
from cdktf import FileProvisioner
from constructs import Construct
from cdktf import Fn, TerraformStack
#
# Provider bindings are generated by running `cdktf get`.
# See https://cdk.tf/provider-generation for more details.
#
from imports.null.resource import Resource
from imports.http. import DataHttp
class MyConvertedCode(TerraformStack):
    def __init__(self, scope, name):
        super().__init__(scope, name)
        data_http_example = DataHttp(self, "example",
            request_headers=[{
                "Accept": "application/json"
            }
            ],
            url="https://checkpoint-api.hashicorp.com/v1/check/terraform"
        )
        null_provider_resource_example = Resource(self, "example_1",
            provisioners=[FileProvisioner(
                type="local-exec",
                command=Fn.contains([201, 204], data_http_example.status_code)
            )
            ]
        )
        # This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.
        null_provider_resource_example.override_logical_id("example")

Schema

Required

Optional

Read-Only

Nested Schema for retry

Optional: