ResourceDataSync class

Provides a SSM resource data sync.

Example Usage

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

const exampleBucket = new aws.s3.Bucket("example", {bucket: "example"});
const exampleResourceDataSync = new aws.ssm.ResourceDataSync("example", {
    s3Destination: {
        bucketName: exampleBucket.bucket,
        region: exampleBucket.region,
    },
    name: "example",
});
const example = aws.iam.getPolicyDocumentOutput({
    statements: [
        {
            principals: [{
                type: "Service",
                identifiers: ["ssm.amazonaws.com"],
            }],
            sid: "SSMBucketPermissionsCheck",
            effect: "Allow",
            actions: ["s3:GetBucketAcl"],
            resources: [exampleBucket.arn],
        },
        {
            conditions: [{
                test: "StringEquals",
                variable: "s3:x-amz-acl",
                values: ["bucket-owner-full-control"],
            }],
            principals: [{
                type: "Service",
                identifiers: ["ssm.amazonaws.com"],
            }],
            sid: "SSMBucketDelivery",
            effect: "Allow",
            actions: ["s3:PutObject"],
            resources: [pulumi.interpolate`${exampleBucket.arn}/*`],
        },
    ],
});
const exampleBucketPolicy = new aws.s3.BucketPolicy("example", {
    bucket: exampleBucket.bucket,
    policy: example.json,
});
import pulumi
import pulumi_aws as aws

example_bucket = aws.s3.Bucket("example", bucket="example")
example_resource_data_sync = aws.ssm.ResourceDataSync("example",
    s3_destination={
        "bucket_name": example_bucket.bucket,
        "region": example_bucket.region,
    },
    name="example")
example = aws.iam.get_policy_document_output(statements=[
    {
        "principals": [{
            "type": "Service",
            "identifiers": ["ssm.amazonaws.com"],
        }],
        "sid": "SSMBucketPermissionsCheck",
        "effect": "Allow",
        "actions": ["s3:GetBucketAcl"],
        "resources": [example_bucket.arn],
    },
    {
        "conditions": [{
            "test": "StringEquals",
            "variable": "s3:x-amz-acl",
            "values": ["bucket-owner-full-control"],
        }],
        "principals": [{
            "type": "Service",
            "identifiers": ["ssm.amazonaws.com"],
        }],
        "sid": "SSMBucketDelivery",
        "effect": "Allow",
        "actions": ["s3:PutObject"],
        "resources": [example_bucket.arn.apply(lambda arn: f"{arn}/*")],
    },
])
example_bucket_policy = aws.s3.BucketPolicy("example",
    bucket=example_bucket.bucket,
    policy=example.json)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var exampleBucket = new Aws.S3.Bucket("example", new()
    {
        BucketName = "example",
    });

    var exampleResourceDataSync = new Aws.Ssm.ResourceDataSync("example", new()
    {
        S3Destination = new Aws.Ssm.Inputs.ResourceDataSyncS3DestinationArgs
        {
            BucketName = exampleBucket.BucketName,
            Region = exampleBucket.Region,
        },
        Name = "example",
    });

    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[]
                        {
                            "ssm.amazonaws.com",
                        },
                    },
                },
                Sid = "SSMBucketPermissionsCheck",
                Effect = "Allow",
                Actions = new[]
                {
                    "s3:GetBucketAcl",
                },
                Resources = new[]
                {
                    exampleBucket.Arn,
                },
            },
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Conditions = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
                    {
                        Test = "StringEquals",
                        Variable = "s3:x-amz-acl",
                        Values = new[]
                        {
                            "bucket-owner-full-control",
                        },
                    },
                },
                Principals = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                    {
                        Type = "Service",
                        Identifiers = new[]
                        {
                            "ssm.amazonaws.com",
                        },
                    },
                },
                Sid = "SSMBucketDelivery",
                Effect = "Allow",
                Actions = new[]
                {
                    "s3:PutObject",
                },
                Resources = new[]
                {
                    $"{exampleBucket.Arn}/*",
                },
            },
        },
    });

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

});
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/ssm"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleBucket, err := s3.NewBucket(ctx, "example", &s3.BucketArgs{
			Bucket: pulumi.String("example"),
		})
		if err != nil {
			return err
		}
		_, err = ssm.NewResourceDataSync(ctx, "example", &ssm.ResourceDataSyncArgs{
			S3Destination: &ssm.ResourceDataSyncS3DestinationArgs{
				BucketName: exampleBucket.Bucket,
				Region:     exampleBucket.Region,
			},
			Name: pulumi.String("example"),
		})
		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("ssm.amazonaws.com"),
							},
						},
					},
					Sid:    pulumi.String("SSMBucketPermissionsCheck"),
					Effect: pulumi.String("Allow"),
					Actions: pulumi.StringArray{
						pulumi.String("s3:GetBucketAcl"),
					},
					Resources: pulumi.StringArray{
						exampleBucket.Arn,
					},
				},
				&iam.GetPolicyDocumentStatementArgs{
					Conditions: iam.GetPolicyDocumentStatementConditionArray{
						&iam.GetPolicyDocumentStatementConditionArgs{
							Test:     pulumi.String("StringEquals"),
							Variable: pulumi.String("s3:x-amz-acl"),
							Values: pulumi.StringArray{
								pulumi.String("bucket-owner-full-control"),
							},
						},
					},
					Principals: iam.GetPolicyDocumentStatementPrincipalArray{
						&iam.GetPolicyDocumentStatementPrincipalArgs{
							Type: pulumi.String("Service"),
							Identifiers: pulumi.StringArray{
								pulumi.String("ssm.amazonaws.com"),
							},
						},
					},
					Sid:    pulumi.String("SSMBucketDelivery"),
					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)
		_, err = s3.NewBucketPolicy(ctx, "example", &s3.BucketPolicyArgs{
			Bucket: exampleBucket.Bucket,
			Policy: example.Json(),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

data "aws_iam_getpolicydocument" "example" {
  statements {
    principals {
      type        = "Service"
      identifiers = ["ssm.amazonaws.com"]
    }
    sid       = "SSMBucketPermissionsCheck"
    effect    = "Allow"
    actions   = ["s3:GetBucketAcl"]
    resources = [aws_s3_bucket.example.arn]
  }
  statements {
    conditions {
      test     = "StringEquals"
      variable = "s3:x-amz-acl"
      values   = ["bucket-owner-full-control"]
    }
    principals {
      type        = "Service"
      identifiers = ["ssm.amazonaws.com"]
    }
    sid       = "SSMBucketDelivery"
    effect    = "Allow"
    actions   = ["s3:PutObject"]
    resources = ["${aws_s3_bucket.example.arn}/*"]
  }
}

resource "aws_ssm_resourcedatasync" "example" {
  s3_destination = {
    bucket_name = aws_s3_bucket.example.bucket
    region      = aws_s3_bucket.example.region
  }
  name = "example"
}
resource "aws_s3_bucket" "example" {
  bucket = "example"
}
resource "aws_s3_bucketpolicy" "example" {
  bucket = aws_s3_bucket.example.bucket
  policy = data.aws_iam_getpolicydocument.example.json
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.s3.Bucket;
import com.pulumi.aws.s3.BucketArgs;
import com.pulumi.aws.ssm.ResourceDataSync;
import com.pulumi.aws.ssm.ResourceDataSyncArgs;
import com.pulumi.aws.ssm.inputs.ResourceDataSyncS3DestinationArgs;
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.iam.inputs.GetPolicyDocumentStatementConditionArgs;
import com.pulumi.aws.s3.BucketPolicy;
import com.pulumi.aws.s3.BucketPolicyArgs;
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 exampleBucket = new Bucket("exampleBucket", BucketArgs.builder()
            .bucket("example")
            .build());

        var exampleResourceDataSync = new ResourceDataSync("exampleResourceDataSync", ResourceDataSyncArgs.builder()
            .s3Destination(ResourceDataSyncS3DestinationArgs.builder()
                .bucketName(exampleBucket.bucket())
                .region(exampleBucket.region())
                .build())
            .name("example")
            .build());

        final var example = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(
                GetPolicyDocumentStatementArgs.builder()
                    .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                        .type("Service")
                        .identifiers("ssm.amazonaws.com")
                        .build())
                    .sid("SSMBucketPermissionsCheck")
                    .effect("Allow")
                    .actions("s3:GetBucketAcl")
                    .resources(exampleBucket.arn())
                    .build(),
                GetPolicyDocumentStatementArgs.builder()
                    .conditions(GetPolicyDocumentStatementConditionArgs.builder()
                        .test("StringEquals")
                        .variable("s3:x-amz-acl")
                        .values("bucket-owner-full-control")
                        .build())
                    .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                        .type("Service")
                        .identifiers("ssm.amazonaws.com")
                        .build())
                    .sid("SSMBucketDelivery")
                    .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.bucket())
            .policy(example.applyValue(_example -> _example.json()))
            .build());

    }
}
resources:
  exampleResourceDataSync:
    type: aws:ssm:ResourceDataSync
    name: example
    properties:
      s3Destination:
        bucketName: ${exampleBucket.bucket}
        region: ${exampleBucket.region}
      name: example
  exampleBucket:
    type: aws:s3:Bucket
    name: example
    properties:
      bucket: example
  exampleBucketPolicy:
    type: aws:s3:BucketPolicy
    name: example
    properties:
      bucket: ${exampleBucket.bucket}
      policy: ${example.json}
variables:
  example:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        statements:
          - principals:
              - type: Service
                identifiers:
                  - ssm.amazonaws.com
            sid: SSMBucketPermissionsCheck
            effect: Allow
            actions:
              - s3:GetBucketAcl
            resources:
              - ${exampleBucket.arn}
          - conditions:
              - test: StringEquals
                variable: s3:x-amz-acl
                values:
                  - bucket-owner-full-control
            principals:
              - type: Service
                identifiers:
                  - ssm.amazonaws.com
            sid: SSMBucketDelivery
            effect: Allow
            actions:
              - s3:PutObject
            resources:
              - ${exampleBucket.arn}/*

Import

Using pulumi import, import SSM resource data sync using the name. For example:

$ pulumi import aws:ssm/resourceDataSync:ResourceDataSync example example-name

Constructors

ResourceDataSync(String name, {ResourceDataSyncArgs? args, CustomResourceOptions? options})
Creates a new ResourceDataSync. name The Pulumi resource name. args Arguments used to configure this ResourceDataSync. The set of arguments for ResourceDataSync. options Resource options controlling this resource's behavior.
ResourceDataSync.reference(String urn)
Creates a typed reference to an existing ResourceDataSync 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
name ↔ Output<String>
Name for the configuration.
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
s3Destination ↔ Output<ResourceDataSyncS3Destination>
Amazon S3 configuration details for the sync.
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, {ResourceDataSyncState? state, CustomResourceOptions? options}) → ResourceDataSync
Gets an existing ResourceDataSync resource's state with the given name and id.