FileSystemPolicy class

Provides an Elastic File System (EFS) File System Policy resource.

Example Usage

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

const fs = new aws.efs.FileSystem("fs", {creationToken: "my-product"});
const policy = aws.iam.getPolicyDocumentOutput({
    statements: [{
        conditions: [{
            test: "Bool",
            variable: "aws:SecureTransport",
            values: ["true"],
        }],
        principals: [{
            type: "AWS",
            identifiers: ["*"],
        }],
        sid: "ExampleStatement01",
        effect: "Allow",
        actions: [
            "elasticfilesystem:ClientMount",
            "elasticfilesystem:ClientWrite",
        ],
        resources: [fs.arn],
    }],
});
const policyFileSystemPolicy = new aws.efs.FileSystemPolicy("policy", {
    fileSystemId: fs.id,
    policy: policy.json,
});
import pulumi
import pulumi_aws as aws

fs = aws.efs.FileSystem("fs", creation_token="my-product")
policy = aws.iam.get_policy_document_output(statements=[{
    "conditions": [{
        "test": "Bool",
        "variable": "aws:SecureTransport",
        "values": ["true"],
    }],
    "principals": [{
        "type": "AWS",
        "identifiers": ["*"],
    }],
    "sid": "ExampleStatement01",
    "effect": "Allow",
    "actions": [
        "elasticfilesystem:ClientMount",
        "elasticfilesystem:ClientWrite",
    ],
    "resources": [fs.arn],
}])
policy_file_system_policy = aws.efs.FileSystemPolicy("policy",
    file_system_id=fs.id,
    policy=policy.json)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var fs = new Aws.Efs.FileSystem("fs", new()
    {
        CreationToken = "my-product",
    });

    var policy = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Conditions = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
                    {
                        Test = "Bool",
                        Variable = "aws:SecureTransport",
                        Values = new[]
                        {
                            "true",
                        },
                    },
                },
                Principals = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                    {
                        Type = "AWS",
                        Identifiers = new[]
                        {
                            "*",
                        },
                    },
                },
                Sid = "ExampleStatement01",
                Effect = "Allow",
                Actions = new[]
                {
                    "elasticfilesystem:ClientMount",
                    "elasticfilesystem:ClientWrite",
                },
                Resources = new[]
                {
                    fs.Arn,
                },
            },
        },
    });

    var policyFileSystemPolicy = new Aws.Efs.FileSystemPolicy("policy", new()
    {
        FileSystemId = fs.Id,
        Policy = policy.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/efs"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		fs, err := efs.NewFileSystem(ctx, "fs", &efs.FileSystemArgs{
			CreationToken: pulumi.String("my-product"),
		})
		if err != nil {
			return err
		}
		policy := iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{
			Statements: iam.GetPolicyDocumentStatementArray{
				&iam.GetPolicyDocumentStatementArgs{
					Conditions: iam.GetPolicyDocumentStatementConditionArray{
						&iam.GetPolicyDocumentStatementConditionArgs{
							Test:     pulumi.String("Bool"),
							Variable: pulumi.String("aws:SecureTransport"),
							Values: pulumi.StringArray{
								pulumi.String("true"),
							},
						},
					},
					Principals: iam.GetPolicyDocumentStatementPrincipalArray{
						&iam.GetPolicyDocumentStatementPrincipalArgs{
							Type: pulumi.String("AWS"),
							Identifiers: pulumi.StringArray{
								pulumi.String("*"),
							},
						},
					},
					Sid:    pulumi.String("ExampleStatement01"),
					Effect: pulumi.String("Allow"),
					Actions: pulumi.StringArray{
						pulumi.String("elasticfilesystem:ClientMount"),
						pulumi.String("elasticfilesystem:ClientWrite"),
					},
					Resources: pulumi.StringArray{
						fs.Arn,
					},
				},
			},
		}, nil)
		_, err = efs.NewFileSystemPolicy(ctx, "policy", &efs.FileSystemPolicyArgs{
			FileSystemId: fs.ID().ToIDOutput().ToStringOutput(),
			Policy:       policy.Json(),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

data "aws_iam_getpolicydocument" "policy" {
  statements {
    conditions {
      test     = "Bool"
      variable = "aws:SecureTransport"
      values   = ["true"]
    }
    principals {
      type        = "AWS"
      identifiers = ["*"]
    }
    sid       = "ExampleStatement01"
    effect    = "Allow"
    actions   = ["elasticfilesystem:ClientMount", "elasticfilesystem:ClientWrite"]
    resources = [aws_efs_filesystem.fs.arn]
  }
}

resource "aws_efs_filesystem" "fs" {
  creation_token = "my-product"
}
resource "aws_efs_filesystempolicy" "policy" {
  file_system_id = aws_efs_filesystem.fs.id
  policy         = data.aws_iam_getpolicydocument.policy.json
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.efs.FileSystem;
import com.pulumi.aws.efs.FileSystemArgs;
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.GetPolicyDocumentStatementConditionArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
import com.pulumi.aws.efs.FileSystemPolicy;
import com.pulumi.aws.efs.FileSystemPolicyArgs;
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 fs = new FileSystem("fs", FileSystemArgs.builder()
            .creationToken("my-product")
            .build());

        final var policy = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .conditions(GetPolicyDocumentStatementConditionArgs.builder()
                    .test("Bool")
                    .variable("aws:SecureTransport")
                    .values("true")
                    .build())
                .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                    .type("AWS")
                    .identifiers("*")
                    .build())
                .sid("ExampleStatement01")
                .effect("Allow")
                .actions(
                    "elasticfilesystem:ClientMount",
                    "elasticfilesystem:ClientWrite")
                .resources(fs.arn())
                .build())
            .build());

        var policyFileSystemPolicy = new FileSystemPolicy("policyFileSystemPolicy", FileSystemPolicyArgs.builder()
            .fileSystemId(fs.id())
            .policy(policy.applyValue(_policy -> _policy.json()))
            .build());

    }
}
resources:
  fs:
    type: aws:efs:FileSystem
    properties:
      creationToken: my-product
  policyFileSystemPolicy:
    type: aws:efs:FileSystemPolicy
    name: policy
    properties:
      fileSystemId: ${fs.id}
      policy: ${policy.json}
variables:
  policy:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        statements:
          - conditions:
              - test: Bool
                variable: aws:SecureTransport
                values:
                  - 'true'
            principals:
              - type: AWS
                identifiers:
                  - '*'
            sid: ExampleStatement01
            effect: Allow
            actions:
              - elasticfilesystem:ClientMount
              - elasticfilesystem:ClientWrite
            resources:
              - ${fs.arn}

Import

Using pulumi import, import the EFS file system policies using the id. For example:

$ pulumi import aws:efs/fileSystemPolicy:FileSystemPolicy foo fs-6fa144c6

Constructors

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

Properties

bypassPolicyLockoutSafetyCheck ↔ Output<bool?>
A flag to indicate whether to bypass the aws.efs.FileSystemPolicy lockout safety check. The policy lockout safety check determines whether the policy in the request will prevent the principal making the request will be locked out from making future PutFileSystemPolicy requests on the file system. Set bypassPolicyLockoutSafetyCheck to true only when you intend to prevent the principal that is making the request from making a subsequent PutFileSystemPolicy request on the file system. The default value is false.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
fileSystemId ↔ Output<String>
The ID of the EFS file system.
latefinal
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
policy ↔ Output<String>
The JSON formatted file system policy for the EFS file system. see Docs for more info.
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
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, {FileSystemPolicyState? state, CustomResourceOptions? options}) → FileSystemPolicy
Gets an existing FileSystemPolicy resource's state with the given name and id.