FolderSink class

Manages a folder-level logging sink. For more information see:

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const log_bucket = new gcp.storage.Bucket("log-bucket", {
    name: "folder-logging-bucket",
    location: "US",
});
const my_folder = new gcp.organizations.Folder("my-folder", {
    displayName: "My folder",
    parent: "organizations/123456",
});
const my_sink = new gcp.logging.FolderSink("my-sink", {
    name: "my-sink",
    description: "some explanation on what this is",
    folder: my_folder.name,
    destination: pulumi.interpolate`storage.googleapis.com/${log_bucket.name}`,
    filter: "resource.type = gce_instance AND severity >= WARNING",
});
const log_writer = new gcp.projects.IAMBinding("log-writer", {
    project: "your-project-id",
    role: "roles/storage.objectCreator",
    members: [my_sink.writerIdentity],
});
import pulumi
import pulumi_gcp as gcp

log_bucket = gcp.storage.Bucket("log-bucket",
    name="folder-logging-bucket",
    location="US")
my_folder = gcp.organizations.Folder("my-folder",
    display_name="My folder",
    parent="organizations/123456")
my_sink = gcp.logging.FolderSink("my-sink",
    name="my-sink",
    description="some explanation on what this is",
    folder=my_folder.name,
    destination=log_bucket.name.apply(lambda name: f"storage.googleapis.com/{name}"),
    filter="resource.type = gce_instance AND severity >= WARNING")
log_writer = gcp.projects.IAMBinding("log-writer",
    project="your-project-id",
    role="roles/storage.objectCreator",
    members=[my_sink.writer_identity])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() =>
{
    var log_bucket = new Gcp.Storage.Bucket("log-bucket", new()
    {
        Name = "folder-logging-bucket",
        Location = "US",
    });

    var my_folder = new Gcp.Organizations.Folder("my-folder", new()
    {
        DisplayName = "My folder",
        Parent = "organizations/123456",
    });

    var my_sink = new Gcp.Logging.FolderSink("my-sink", new()
    {
        Name = "my-sink",
        Description = "some explanation on what this is",
        Folder = my_folder.Name,
        Destination = log_bucket.Name.Apply(name => $"storage.googleapis.com/{name}"),
        Filter = "resource.type = gce_instance AND severity >= WARNING",
    });

    var log_writer = new Gcp.Projects.IAMBinding("log-writer", new()
    {
        Project = "your-project-id",
        Role = "roles/storage.objectCreator",
        Members = new[]
        {
            my_sink.WriterIdentity,
        },
    });

});
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/logging"
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/organizations"
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/projects"
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/storage"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		log_bucket, err := storage.NewBucket(ctx, "log-bucket", &storage.BucketArgs{
			Name:     pulumi.String("folder-logging-bucket"),
			Location: pulumi.String("US"),
		})
		if err != nil {
			return err
		}
		my_folder, err := organizations.NewFolder(ctx, "my-folder", &organizations.FolderArgs{
			DisplayName: pulumi.String("My folder"),
			Parent:      pulumi.String("organizations/123456"),
		})
		if err != nil {
			return err
		}
		my_sink, err := logging.NewFolderSink(ctx, "my-sink", &logging.FolderSinkArgs{
			Name:        pulumi.String("my-sink"),
			Description: pulumi.String("some explanation on what this is"),
			Folder:      my_folder.Name,
			Destination: log_bucket.Name.ApplyT(func(name string) (string, error) {
				return fmt.Sprintf("storage.googleapis.com/%v", name), nil
			}).(pulumi.StringOutput),
			Filter: pulumi.String("resource.type = gce_instance AND severity >= WARNING"),
		})
		if err != nil {
			return err
		}
		_, err = projects.NewIAMBinding(ctx, "log-writer", &projects.IAMBindingArgs{
			Project: pulumi.String("your-project-id"),
			Role:    pulumi.String("roles/storage.objectCreator"),
			Members: pulumi.StringArray{
				my_sink.WriterIdentity,
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    gcp = {
      source = "pulumi/gcp"
    }
  }
}

resource "gcp_logging_foldersink" "my-sink" {
  name        = "my-sink"
  description = "some explanation on what this is"
  folder      = gcp_organizations_folder.my-folder.name
  destination ="storage.googleapis.com/${gcp_storage_bucket.log-bucket.name}"
  filter      = "resource.type = gce_instance AND severity >= WARNING"
}
resource "gcp_storage_bucket" "log-bucket" {
  name     = "folder-logging-bucket"
  location = "US"
}
resource "gcp_projects_iambinding" "log-writer" {
  project = "your-project-id"
  role    = "roles/storage.objectCreator"
  members = [gcp_logging_foldersink.my-sink.writer_identity]
}
resource "gcp_organizations_folder" "my-folder" {
  display_name = "My folder"
  parent       = "organizations/123456"
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.storage.Bucket;
import com.pulumi.gcp.storage.BucketArgs;
import com.pulumi.gcp.organizations.Folder;
import com.pulumi.gcp.organizations.FolderArgs;
import com.pulumi.gcp.logging.FolderSink;
import com.pulumi.gcp.logging.FolderSinkArgs;
import com.pulumi.gcp.projects.IAMBinding;
import com.pulumi.gcp.projects.IAMBindingArgs;
import java.util.ArrayList;
import java.util.Arrays;
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) {
        var log_bucket = new Bucket("log-bucket", BucketArgs.builder()
            .name("folder-logging-bucket")
            .location("US")
            .build());

        var my_folder = new Folder("my-folder", FolderArgs.builder()
            .displayName("My folder")
            .parent("organizations/123456")
            .build());

        var my_sink = new FolderSink("my-sink", FolderSinkArgs.builder()
            .name("my-sink")
            .description("some explanation on what this is")
            .folder(my_folder.name())
            .destination(log_bucket.name().applyValue(_name -> String.format("storage.googleapis.com/%s", _name)))
            .filter("resource.type = gce_instance AND severity >= WARNING")
            .build());

        var log_writer = new IAMBinding("log-writer", IAMBindingArgs.builder()
            .project("your-project-id")
            .role("roles/storage.objectCreator")
            .members(my_sink.writerIdentity())
            .build());

    }
}
resources:
  my-sink:
    type: gcp:logging:FolderSink
    properties:
      name: my-sink
      description: some explanation on what this is
      folder: ${["my-folder"].name}
      destination: storage.googleapis.com/${["log-bucket"].name}
      filter: resource.type = gce_instance AND severity >= WARNING
  log-bucket:
    type: gcp:storage:Bucket
    properties:
      name: folder-logging-bucket
      location: US
  log-writer:
    type: gcp:projects:IAMBinding
    properties:
      project: your-project-id
      role: roles/storage.objectCreator
      members:
        - ${["my-sink"].writerIdentity}
  my-folder:
    type: gcp:organizations:Folder
    properties:
      displayName: My folder
      parent: organizations/123456

Import

Folder-level logging sinks can be imported using this format:

  • folders/{{folder_id}}/sinks/{{name}}

When using the pulumi import command, folder-level logging sinks can be imported using one of the formats above. For example:

$ pulumi import gcp:logging/folderSink:FolderSink default folders/{{folder_id}}/sinks/{{name}}

Constructors

FolderSink(String name, {FolderSinkArgs? args, CustomResourceOptions? options})
Creates a new FolderSink. name The Pulumi resource name. args Arguments used to configure this FolderSink. The set of arguments for FolderSink. options Resource options controlling this resource's behavior.
FolderSink.reference(String urn)
Creates a typed reference to an existing FolderSink resource.

Properties

bigqueryOptions ↔ Output<FolderSinkBigqueryOptions>
Options that affect sinks exporting data to BigQuery. Structure documented below.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
deletionPolicy ↔ Output<String>
Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". When a 'terraform destroy' or 'pulumi up' would delete the resource, the command will fail if this field is set to "PREVENT" in Terraform state. When set to "ABANDON", the command will remove the resource from Terraform management without updating or deleting the resource in the API. When set to "DELETE", deleting the resource is allowed.
latefinal
description ↔ Output<String?>
A description of this sink. The maximum length of the description is 8000 characters.
latefinal
destination ↔ Output<String>
The destination of the sink (or, in other words, where logs are written to). Can be a Cloud Storage bucket, a PubSub topic, a BigQuery dataset, a Cloud Logging bucket, or a Google Cloud project. Examples:
latefinal
disabled ↔ Output<bool?>
If set to True, then this sink is disabled and it does not export any log entries.
latefinal
exclusions ↔ Output<List<FolderSinkExclusion>?>
Log entries that match any of the exclusion filters will not be exported. If a log entry is matched by both filter and one of exclusions.filter, it will not be exported. Can be repeated multiple times for multiple exclusions. Structure is documented below.
latefinal
filter ↔ Output<String?>
The filter to apply when exporting logs. Only log entries that match the filter are exported. See Advanced Log Filters for information on how to write a filter.
latefinal
folder ↔ Output<String>
The folder to be exported to the sink. Note that either [FOLDER_ID] or folders/[FOLDER_ID] is accepted.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
includeChildren ↔ Output<bool?>
Whether or not to include children folders in the sink export. If true, logs associated with child projects are also exported; otherwise only logs relating to the provided folder are included.
latefinal
interceptChildren ↔ Output<bool?>
Whether or not to intercept logs from child projects. If true, matching logs will not match with sinks in child resources, except _Required sinks. This sink will be visible to child resources when listing sinks.
latefinal
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
name ↔ Output<String>
The name of the logging sink.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited
writerIdentity ↔ Output<String>
The identity associated with this sink. This identity must be granted write access to the configured destination.
latefinal

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {FolderSinkState? state, CustomResourceOptions? options}) → FolderSink
Gets an existing FolderSink resource's state with the given name and id.