SessionLoggerAssociation class

Resource for managing an AWS WorkSpaces Web Session Logger Association.

Example Usage

Basic Usage

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

const examplePortal = new aws.workspacesweb.Portal("example", {displayName: "example"});
const exampleBucket = new aws.s3.Bucket("example", {
    bucket: "example-session-logs",
    forceDestroy: true,
});
const example = aws.iam.getPolicyDocumentOutput({
    statements: [{
        principals: [{
            type: "Service",
            identifiers: ["workspaces-web.amazonaws.com"],
        }],
        effect: "Allow",
        actions: ["s3:PutObject"],
        resources: [pulumi.interpolate`${exampleBucket.arn}/*`],
    }],
});
const exampleBucketPolicy = new aws.s3.BucketPolicy("example", {
    bucket: exampleBucket.id,
    policy: example.json,
});
const exampleSessionLogger = new aws.workspacesweb.SessionLogger("example", {
    eventFilter: {
        all: {}[0],
    },
    logConfiguration: {
        s3: {
            bucket: exampleBucket.id,
            folderStructure: "Flat",
            logFileFormat: "Json",
        },
    },
    displayName: "example",
}, {
    dependsOn: [exampleBucketPolicy],
});
const exampleSessionLoggerAssociation = new aws.workspacesweb.SessionLoggerAssociation("example", {
    portalArn: examplePortal.portalArn,
    sessionLoggerArn: exampleSessionLogger.sessionLoggerArn,
});
import pulumi
import pulumi_aws as aws

example_portal = aws.workspacesweb.Portal("example", display_name="example")
example_bucket = aws.s3.Bucket("example",
    bucket="example-session-logs",
    force_destroy=True)
example = aws.iam.get_policy_document_output(statements=[{
    "principals": [{
        "type": "Service",
        "identifiers": ["workspaces-web.amazonaws.com"],
    }],
    "effect": "Allow",
    "actions": ["s3:PutObject"],
    "resources": [example_bucket.arn.apply(lambda arn: f"{arn}/*")],
}])
example_bucket_policy = aws.s3.BucketPolicy("example",
    bucket=example_bucket.id,
    policy=example.json)
example_session_logger = aws.workspacesweb.SessionLogger("example",
    event_filter={
        "all": {}[0],
    },
    log_configuration={
        "s3": {
            "bucket": example_bucket.id,
            "folder_structure": "Flat",
            "log_file_format": "Json",
        },
    },
    display_name="example",
    opts = pulumi.ResourceOptions(depends_on=[example_bucket_policy]))
example_session_logger_association = aws.workspacesweb.SessionLoggerAssociation("example",
    portal_arn=example_portal.portal_arn,
    session_logger_arn=example_session_logger.session_logger_arn)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var examplePortal = new Aws.WorkSpacesWeb.Portal("example", new()
    {
        DisplayName = "example",
    });

    var exampleBucket = new Aws.S3.Bucket("example", new()
    {
        BucketName = "example-session-logs",
        ForceDestroy = true,
    });

    var example = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Principals = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                    {
                        Type = "Service",
                        Identifiers = new[]
                        {
                            "workspaces-web.amazonaws.com",
                        },
                    },
                },
                Effect = "Allow",
                Actions = new[]
                {
                    "s3:PutObject",
                },
                Resources = new[]
                {
                    $"{exampleBucket.Arn}/*",
                },
            },
        },
    });

    var exampleBucketPolicy = new Aws.S3.BucketPolicy("example", new()
    {
        Bucket = exampleBucket.Id,
        Policy = example.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
    });

    var exampleSessionLogger = new Aws.WorkSpacesWeb.SessionLogger("example", new()
    {
        EventFilter = new Aws.WorkSpacesWeb.Inputs.SessionLoggerEventFilterArgs
        {
            All = null[0],
        },
        LogConfiguration = new Aws.WorkSpacesWeb.Inputs.SessionLoggerLogConfigurationArgs
        {
            S3 = new Aws.WorkSpacesWeb.Inputs.SessionLoggerLogConfigurationS3Args
            {
                Bucket = exampleBucket.Id,
                FolderStructure = "Flat",
                LogFileFormat = "Json",
            },
        },
        DisplayName = "example",
    }, new CustomResourceOptions
    {
        DependsOn =
        {
            exampleBucketPolicy,
        },
    });

    var exampleSessionLoggerAssociation = new Aws.WorkSpacesWeb.SessionLoggerAssociation("example", new()
    {
        PortalArn = examplePortal.PortalArn,
        SessionLoggerArn = exampleSessionLogger.SessionLoggerArn,
    });

});
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/s3"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/workspacesweb"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		examplePortal, err := workspacesweb.NewPortal(ctx, "example", &workspacesweb.PortalArgs{
			DisplayName: pulumi.String("example"),
		})
		if err != nil {
			return err
		}
		exampleBucket, err := s3.NewBucket(ctx, "example", &s3.BucketArgs{
			Bucket:       pulumi.String("example-session-logs"),
			ForceDestroy: pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		example := iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{
			Statements: iam.GetPolicyDocumentStatementArray{
				&iam.GetPolicyDocumentStatementArgs{
					Principals: iam.GetPolicyDocumentStatementPrincipalArray{
						&iam.GetPolicyDocumentStatementPrincipalArgs{
							Type: pulumi.String("Service"),
							Identifiers: pulumi.StringArray{
								pulumi.String("workspaces-web.amazonaws.com"),
							},
						},
					},
					Effect: pulumi.String("Allow"),
					Actions: pulumi.StringArray{
						pulumi.String("s3:PutObject"),
					},
					Resources: pulumi.StringArray{
						exampleBucket.Arn.ApplyT(func(arn string) (string, error) {
							return fmt.Sprintf("%v/*", arn), nil
						}).(pulumi.StringOutput),
					},
				},
			},
		}, nil)
		exampleBucketPolicy, err := s3.NewBucketPolicy(ctx, "example", &s3.BucketPolicyArgs{
			Bucket: exampleBucket.ID().ToIDOutput().ToStringOutput(),
			Policy: example.Json(),
		})
		if err != nil {
			return err
		}
		exampleSessionLogger, err := workspacesweb.NewSessionLogger(ctx, "example", &workspacesweb.SessionLoggerArgs{
			EventFilter: &workspacesweb.SessionLoggerEventFilterArgs{
				All: map[string]interface{}{}[0],
			},
			LogConfiguration: &workspacesweb.SessionLoggerLogConfigurationArgs{
				S3: &workspacesweb.SessionLoggerLogConfigurationS3Args{
					Bucket:          exampleBucket.ID().ToIDOutput().ToStringOutput(),
					FolderStructure: pulumi.String("Flat"),
					LogFileFormat:   pulumi.String("Json"),
				},
			},
			DisplayName: pulumi.String("example"),
		}, pulumi.DependsOn([]pulumi.Resource{
			exampleBucketPolicy,
		}))
		if err != nil {
			return err
		}
		_, err = workspacesweb.NewSessionLoggerAssociation(ctx, "example", &workspacesweb.SessionLoggerAssociationArgs{
			PortalArn:        examplePortal.PortalArn,
			SessionLoggerArn: exampleSessionLogger.SessionLoggerArn,
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

data "aws_iam_getpolicydocument" "example" {
  statements {
    principals {
      type        = "Service"
      identifiers = ["workspaces-web.amazonaws.com"]
    }
    effect    = "Allow"
    actions   = ["s3:PutObject"]
    resources = ["${aws_s3_bucket.example.arn}/*"]
  }
}

resource "aws_workspacesweb_portal" "example" {
  display_name = "example"
}
resource "aws_s3_bucket" "example" {
  bucket        = "example-session-logs"
  force_destroy = true
}
resource "aws_s3_bucketpolicy" "example" {
  bucket = aws_s3_bucket.example.id
  policy = data.aws_iam_getpolicydocument.example.json
}
resource "aws_workspacesweb_sessionlogger" "example" {
  depends_on = [aws_s3_bucketpolicy.example]
  event_filter = {
    all = {}[0]
  }
  log_configuration = {
    s3 = {
      bucket           = aws_s3_bucket.example.id
      folder_structure = "Flat"
      log_file_format  = "Json"
    }
  }
  display_name = "example"
}
resource "aws_workspacesweb_sessionloggerassociation" "example" {
  portal_arn         = aws_workspacesweb_portal.example.portal_arn
  session_logger_arn = aws_workspacesweb_sessionlogger.example.session_logger_arn
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.workspacesweb.Portal;
import com.pulumi.aws.workspacesweb.PortalArgs;
import com.pulumi.aws.s3.Bucket;
import com.pulumi.aws.s3.BucketArgs;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
import com.pulumi.aws.s3.BucketPolicy;
import com.pulumi.aws.s3.BucketPolicyArgs;
import com.pulumi.aws.workspacesweb.SessionLogger;
import com.pulumi.aws.workspacesweb.SessionLoggerArgs;
import com.pulumi.aws.workspacesweb.inputs.SessionLoggerEventFilterArgs;
import com.pulumi.aws.workspacesweb.inputs.SessionLoggerLogConfigurationArgs;
import com.pulumi.aws.workspacesweb.inputs.SessionLoggerLogConfigurationS3Args;
import com.pulumi.aws.workspacesweb.SessionLoggerAssociation;
import com.pulumi.aws.workspacesweb.SessionLoggerAssociationArgs;
import com.pulumi.resources.CustomResourceOptions;
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 examplePortal = new Portal("examplePortal", PortalArgs.builder()
            .displayName("example")
            .build());

        var exampleBucket = new Bucket("exampleBucket", BucketArgs.builder()
            .bucket("example-session-logs")
            .forceDestroy(true)
            .build());

        final var example = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                    .type("Service")
                    .identifiers("workspaces-web.amazonaws.com")
                    .build())
                .effect("Allow")
                .actions("s3:PutObject")
                .resources(exampleBucket.arn().applyValue(_arn -> String.format("%s/*", _arn)))
                .build())
            .build());

        var exampleBucketPolicy = new BucketPolicy("exampleBucketPolicy", BucketPolicyArgs.builder()
            .bucket(exampleBucket.id())
            .policy(example.applyValue(_example -> _example.json()))
            .build());

        var exampleSessionLogger = new SessionLogger("exampleSessionLogger", SessionLoggerArgs.builder()
            .eventFilter(SessionLoggerEventFilterArgs.builder()
                .all(com.pulumi.aws.workspacesweb.inputs.SessionLoggerEventFilterAllArgs.builder()
                    .build()[0])
                .build())
            .logConfiguration(SessionLoggerLogConfigurationArgs.builder()
                .s3(SessionLoggerLogConfigurationS3Args.builder()
                    .bucket(exampleBucket.id())
                    .folderStructure("Flat")
                    .logFileFormat("Json")
                    .build())
                .build())
            .displayName("example")
            .build(), CustomResourceOptions.builder()
                .dependsOn(exampleBucketPolicy)
                .build());

        var exampleSessionLoggerAssociation = new SessionLoggerAssociation("exampleSessionLoggerAssociation", SessionLoggerAssociationArgs.builder()
            .portalArn(examplePortal.portalArn())
            .sessionLoggerArn(exampleSessionLogger.sessionLoggerArn())
            .build());

    }
}

Import

Using pulumi import, import WorkSpaces Web Session Logger Association using the session_logger_arn,portal_arn. For example:

$ pulumi import aws:workspacesweb/sessionLoggerAssociation:SessionLoggerAssociation example arn:aws:workspaces-web:us-west-2:123456789012:sessionLogger/session_logger-id-12345678,arn:aws:workspaces-web:us-west-2:123456789012:portal/portal-id-12345678

Constructors

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

Properties

childResources Set<Resource>
finalinherited
completionSources Map<String, IOutputCompletionSource>
latefinalinherited
hashCode int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
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
portalArn ↔ Output<String>
ARN of the web portal.
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceTransforms List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sessionLoggerArn ↔ Output<String>
ARN of the session logger.
latefinal
transformations List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited

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, {SessionLoggerAssociationState? state, CustomResourceOptions? options}) SessionLoggerAssociation
Gets an existing SessionLoggerAssociation resource's state with the given name and id.