com.pulumi.cloudflare.kotlin.ManagedHeaders.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-cloudflare-kotlin Show documentation
Show all versions of pulumi-cloudflare-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
The newest version!
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.cloudflare.kotlin
import com.pulumi.cloudflare.kotlin.outputs.ManagedHeadersManagedRequestHeader
import com.pulumi.cloudflare.kotlin.outputs.ManagedHeadersManagedResponseHeader
import com.pulumi.core.Output
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import com.pulumi.cloudflare.kotlin.outputs.ManagedHeadersManagedRequestHeader.Companion.toKotlin as managedHeadersManagedRequestHeaderToKotlin
import com.pulumi.cloudflare.kotlin.outputs.ManagedHeadersManagedResponseHeader.Companion.toKotlin as managedHeadersManagedResponseHeaderToKotlin
/**
* Builder for [ManagedHeaders].
*/
@PulumiTagMarker
public class ManagedHeadersResourceBuilder internal constructor() {
public var name: String? = null
public var args: ManagedHeadersArgs = ManagedHeadersArgs()
public var opts: CustomResourceOptions = CustomResourceOptions()
/**
* @param name The _unique_ name of the resulting resource.
*/
public fun name(`value`: String) {
this.name = value
}
/**
* @param block The arguments to use to populate this resource's properties.
*/
public suspend fun args(block: suspend ManagedHeadersArgsBuilder.() -> Unit) {
val builder = ManagedHeadersArgsBuilder()
block(builder)
this.args = builder.build()
}
/**
* @param block A bag of options that control this resource's behavior.
*/
public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
}
internal fun build(): ManagedHeaders {
val builtJavaResource = com.pulumi.cloudflare.ManagedHeaders(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return ManagedHeaders(builtJavaResource)
}
}
/**
* The [Cloudflare Managed Headers](https://developers.cloudflare.com/rules/transform/managed-transforms/)
* allows you to add or remove some predefined headers to one's
* requests or origin responses.
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as cloudflare from "@pulumi/cloudflare";
* // Enable security headers using Managed Meaders
* const example = new cloudflare.ManagedHeaders("example", {
* zoneId: "0da42c8d2132a9ddaf714f9e7c920711",
* managedRequestHeaders: [{
* id: "add_true_client_ip_headers",
* enabled: true,
* }],
* managedResponseHeaders: [{
* id: "remove_x-powered-by_header",
* enabled: true,
* }],
* });
* ```
* ```python
* import pulumi
* import pulumi_cloudflare as cloudflare
* # Enable security headers using Managed Meaders
* example = cloudflare.ManagedHeaders("example",
* zone_id="0da42c8d2132a9ddaf714f9e7c920711",
* managed_request_headers=[{
* "id": "add_true_client_ip_headers",
* "enabled": True,
* }],
* managed_response_headers=[{
* "id": "remove_x-powered-by_header",
* "enabled": True,
* }])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Cloudflare = Pulumi.Cloudflare;
* return await Deployment.RunAsync(() =>
* {
* // Enable security headers using Managed Meaders
* var example = new Cloudflare.ManagedHeaders("example", new()
* {
* ZoneId = "0da42c8d2132a9ddaf714f9e7c920711",
* ManagedRequestHeaders = new[]
* {
* new Cloudflare.Inputs.ManagedHeadersManagedRequestHeaderArgs
* {
* Id = "add_true_client_ip_headers",
* Enabled = true,
* },
* },
* ManagedResponseHeaders = new[]
* {
* new Cloudflare.Inputs.ManagedHeadersManagedResponseHeaderArgs
* {
* Id = "remove_x-powered-by_header",
* Enabled = true,
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* // Enable security headers using Managed Meaders
* _, err := cloudflare.NewManagedHeaders(ctx, "example", &cloudflare.ManagedHeadersArgs{
* ZoneId: pulumi.String("0da42c8d2132a9ddaf714f9e7c920711"),
* ManagedRequestHeaders: cloudflare.ManagedHeadersManagedRequestHeaderArray{
* &cloudflare.ManagedHeadersManagedRequestHeaderArgs{
* Id: pulumi.String("add_true_client_ip_headers"),
* Enabled: pulumi.Bool(true),
* },
* },
* ManagedResponseHeaders: cloudflare.ManagedHeadersManagedResponseHeaderArray{
* &cloudflare.ManagedHeadersManagedResponseHeaderArgs{
* Id: pulumi.String("remove_x-powered-by_header"),
* Enabled: pulumi.Bool(true),
* },
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.cloudflare.ManagedHeaders;
* import com.pulumi.cloudflare.ManagedHeadersArgs;
* import com.pulumi.cloudflare.inputs.ManagedHeadersManagedRequestHeaderArgs;
* import com.pulumi.cloudflare.inputs.ManagedHeadersManagedResponseHeaderArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* // Enable security headers using Managed Meaders
* var example = new ManagedHeaders("example", ManagedHeadersArgs.builder()
* .zoneId("0da42c8d2132a9ddaf714f9e7c920711")
* .managedRequestHeaders(ManagedHeadersManagedRequestHeaderArgs.builder()
* .id("add_true_client_ip_headers")
* .enabled(true)
* .build())
* .managedResponseHeaders(ManagedHeadersManagedResponseHeaderArgs.builder()
* .id("remove_x-powered-by_header")
* .enabled(true)
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* # Enable security headers using Managed Meaders
* example:
* type: cloudflare:ManagedHeaders
* properties:
* zoneId: 0da42c8d2132a9ddaf714f9e7c920711
* managedRequestHeaders:
* - id: add_true_client_ip_headers
* enabled: true
* managedResponseHeaders:
* - id: remove_x-powered-by_header
* enabled: true
* ```
*
*/
public class ManagedHeaders internal constructor(
override val javaResource: com.pulumi.cloudflare.ManagedHeaders,
) : KotlinCustomResource(javaResource, ManagedHeadersMapper) {
/**
* The list of managed request headers.
*/
public val managedRequestHeaders: Output>?
get() = javaResource.managedRequestHeaders().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
managedHeadersManagedRequestHeaderToKotlin(args0)
})
})
}).orElse(null)
})
/**
* The list of managed response headers.
*/
public val managedResponseHeaders: Output>?
get() = javaResource.managedResponseHeaders().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
managedHeadersManagedResponseHeaderToKotlin(args0)
})
})
}).orElse(null)
})
/**
* The zone identifier to target for the resource.
*/
public val zoneId: Output
get() = javaResource.zoneId().applyValue({ args0 -> args0 })
}
public object ManagedHeadersMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.cloudflare.ManagedHeaders::class == javaResource::class
override fun map(javaResource: Resource): ManagedHeaders = ManagedHeaders(
javaResource as
com.pulumi.cloudflare.ManagedHeaders,
)
}
/**
* @see [ManagedHeaders].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [ManagedHeaders].
*/
public suspend fun managedHeaders(
name: String,
block: suspend ManagedHeadersResourceBuilder.() -> Unit,
): ManagedHeaders {
val builder = ManagedHeadersResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [ManagedHeaders].
* @param name The _unique_ name of the resulting resource.
*/
public fun managedHeaders(name: String): ManagedHeaders {
val builder = ManagedHeadersResourceBuilder()
builder.name(name)
return builder.build()
}