Domain class

Resource for managing an AWS DataZone Domain.

Example Usage

Basic Usage

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

const domainExecutionRole = new aws.iam.Role("domain_execution_role", {
    name: "my_domain_execution_role",
    assumeRolePolicy: JSON.stringify({
        Version: "2012-10-17",
        Statement: [
            {
                Action: [
                    "sts:AssumeRole",
                    "sts:TagSession",
                ],
                Effect: "Allow",
                Principal: {
                    Service: "datazone.amazonaws.com",
                },
            },
            {
                Action: [
                    "sts:AssumeRole",
                    "sts:TagSession",
                ],
                Effect: "Allow",
                Principal: {
                    Service: "cloudformation.amazonaws.com",
                },
            },
        ],
    }),
});
const domainExecutionRoleRolePolicy = new aws.iam.RolePolicy("domain_execution_role", {
    role: domainExecutionRole.name,
    policy: JSON.stringify({
        Version: "2012-10-17",
        Statement: [{
            Action: [
                "datazone:*",
                "ram:*",
                "sso:*",
                "kms:*",
            ],
            Effect: "Allow",
            Resource: "*",
        }],
    }),
});
const example = new aws.datazone.Domain("example", {
    name: "example",
    domainExecutionRole: domainExecutionRole.arn,
});
import pulumi
import json
import pulumi_aws as aws

domain_execution_role = aws.iam.Role("domain_execution_role",
    name="my_domain_execution_role",
    assume_role_policy=json.dumps({
        "Version": "2012-10-17",
        "Statement": [
            {
                "Action": [
                    "sts:AssumeRole",
                    "sts:TagSession",
                ],
                "Effect": "Allow",
                "Principal": {
                    "Service": "datazone.amazonaws.com",
                },
            },
            {
                "Action": [
                    "sts:AssumeRole",
                    "sts:TagSession",
                ],
                "Effect": "Allow",
                "Principal": {
                    "Service": "cloudformation.amazonaws.com",
                },
            },
        ],
    }))
domain_execution_role_role_policy = aws.iam.RolePolicy("domain_execution_role",
    role=domain_execution_role.name,
    policy=json.dumps({
        "Version": "2012-10-17",
        "Statement": [{
            "Action": [
                "datazone:*",
                "ram:*",
                "sso:*",
                "kms:*",
            ],
            "Effect": "Allow",
            "Resource": "*",
        }],
    }))
example = aws.datazone.Domain("example",
    name="example",
    domain_execution_role=domain_execution_role.arn)
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var domainExecutionRole = new Aws.Iam.Role("domain_execution_role", new()
    {
        Name = "my_domain_execution_role",
        AssumeRolePolicy = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["Version"] = "2012-10-17",
            ["Statement"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["Action"] = new[]
                    {
                        "sts:AssumeRole",
                        "sts:TagSession",
                    },
                    ["Effect"] = "Allow",
                    ["Principal"] = new Dictionary<string, object?>
                    {
                        ["Service"] = "datazone.amazonaws.com",
                    },
                },
                new Dictionary<string, object?>
                {
                    ["Action"] = new[]
                    {
                        "sts:AssumeRole",
                        "sts:TagSession",
                    },
                    ["Effect"] = "Allow",
                    ["Principal"] = new Dictionary<string, object?>
                    {
                        ["Service"] = "cloudformation.amazonaws.com",
                    },
                },
            },
        }),
    });

    var domainExecutionRoleRolePolicy = new Aws.Iam.RolePolicy("domain_execution_role", new()
    {
        Role = domainExecutionRole.Name,
        Policy = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["Version"] = "2012-10-17",
            ["Statement"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["Action"] = new[]
                    {
                        "datazone:*",
                        "ram:*",
                        "sso:*",
                        "kms:*",
                    },
                    ["Effect"] = "Allow",
                    ["Resource"] = "*",
                },
            },
        }),
    });

    var example = new Aws.DataZone.Domain("example", new()
    {
        Name = "example",
        DomainExecutionRole = domainExecutionRole.Arn,
    });

});
package main

import (
	"encoding/json"

	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/datazone"
	"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 {
		tmpJSON0, err := json.Marshal(map[string]interface{}{
			"Version": "2012-10-17",
			"Statement": []map[string]interface{}{
				map[string]interface{}{
					"Action": []string{
						"sts:AssumeRole",
						"sts:TagSession",
					},
					"Effect": "Allow",
					"Principal": map[string]string{
						"Service": "datazone.amazonaws.com",
					},
				},
				map[string]interface{}{
					"Action": []string{
						"sts:AssumeRole",
						"sts:TagSession",
					},
					"Effect": "Allow",
					"Principal": map[string]string{
						"Service": "cloudformation.amazonaws.com",
					},
				},
			},
		})
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		domainExecutionRole, err := iam.NewRole(ctx, "domain_execution_role", &iam.RoleArgs{
			Name:             pulumi.String("my_domain_execution_role"),
			AssumeRolePolicy: pulumi.String(json0),
		})
		if err != nil {
			return err
		}
		tmpJSON1, err := json.Marshal(map[string]interface{}{
			"Version": "2012-10-17",
			"Statement": []map[string]interface{}{
				map[string]interface{}{
					"Action": []string{
						"datazone:*",
						"ram:*",
						"sso:*",
						"kms:*",
					},
					"Effect":   "Allow",
					"Resource": "*",
				},
			},
		})
		if err != nil {
			return err
		}
		json1 := string(tmpJSON1)
		_, err = iam.NewRolePolicy(ctx, "domain_execution_role", &iam.RolePolicyArgs{
			Role:   domainExecutionRole.Name,
			Policy: pulumi.String(json1),
		})
		if err != nil {
			return err
		}
		_, err = datazone.NewDomain(ctx, "example", &datazone.DomainArgs{
			Name:                pulumi.String("example"),
			DomainExecutionRole: domainExecutionRole.Arn,
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_iam_role" "domain_execution_role" {
  name = "my_domain_execution_role"
  assume_role_policy = jsonencode({
    "Version" = "2012-10-17"
    "Statement" = [{
      "Action" = ["sts:AssumeRole", "sts:TagSession"]
      "Effect" = "Allow"
      "Principal" = {
        "Service" = "datazone.amazonaws.com"
      }
      }, {
      "Action" = ["sts:AssumeRole", "sts:TagSession"]
      "Effect" = "Allow"
      "Principal" = {
        "Service" = "cloudformation.amazonaws.com"
      }
    }]
  })
}
resource "aws_iam_rolepolicy" "domain_execution_role" {
  role = aws_iam_role.domain_execution_role.name
  policy = jsonencode({
    "Version" = "2012-10-17"
    "Statement" = [{
      "Action"   = ["datazone:*", "ram:*", "sso:*", "kms:*"]
      "Effect"   = "Allow"
      "Resource" = "*"
    }]
  })
}
resource "aws_datazone_domain" "example" {
  name                  = "example"
  domain_execution_role = aws_iam_role.domain_execution_role.arn
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import com.pulumi.aws.iam.RolePolicy;
import com.pulumi.aws.iam.RolePolicyArgs;
import com.pulumi.aws.datazone.Domain;
import com.pulumi.aws.datazone.DomainArgs;
import static com.pulumi.codegen.internal.Serialization.*;
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 domainExecutionRole = new Role("domainExecutionRole", RoleArgs.builder()
            .name("my_domain_execution_role")
            .assumeRolePolicy(serializeJson(
                jsonObject(
                    jsonProperty("Version", "2012-10-17"),
                    jsonProperty("Statement", jsonArray(
                        jsonObject(
                            jsonProperty("Action", jsonArray(
                                "sts:AssumeRole",
                                "sts:TagSession"
                            )),
                            jsonProperty("Effect", "Allow"),
                            jsonProperty("Principal", jsonObject(
                                jsonProperty("Service", "datazone.amazonaws.com")
                            ))
                        ),
                        jsonObject(
                            jsonProperty("Action", jsonArray(
                                "sts:AssumeRole",
                                "sts:TagSession"
                            )),
                            jsonProperty("Effect", "Allow"),
                            jsonProperty("Principal", jsonObject(
                                jsonProperty("Service", "cloudformation.amazonaws.com")
                            ))
                        )
                    ))
                )))
            .build());

        var domainExecutionRoleRolePolicy = new RolePolicy("domainExecutionRoleRolePolicy", RolePolicyArgs.builder()
            .role(domainExecutionRole.name())
            .policy(serializeJson(
                jsonObject(
                    jsonProperty("Version", "2012-10-17"),
                    jsonProperty("Statement", jsonArray(jsonObject(
                        jsonProperty("Action", jsonArray(
                            "datazone:*",
                            "ram:*",
                            "sso:*",
                            "kms:*"
                        )),
                        jsonProperty("Effect", "Allow"),
                        jsonProperty("Resource", "*")
                    )))
                )))
            .build());

        var example = new Domain("example", DomainArgs.builder()
            .name("example")
            .domainExecutionRole(domainExecutionRole.arn())
            .build());

    }
}
resources:
  domainExecutionRole:
    type: aws:iam:Role
    name: domain_execution_role
    properties:
      name: my_domain_execution_role
      assumeRolePolicy:
        fn::toJSON:
          Version: 2012-10-17
          Statement:
            - Action:
                - sts:AssumeRole
                - sts:TagSession
              Effect: Allow
              Principal:
                Service: datazone.amazonaws.com
            - Action:
                - sts:AssumeRole
                - sts:TagSession
              Effect: Allow
              Principal:
                Service: cloudformation.amazonaws.com
  domainExecutionRoleRolePolicy:
    type: aws:iam:RolePolicy
    name: domain_execution_role
    properties:
      role: ${domainExecutionRole.name}
      policy:
        fn::toJSON:
          Version: 2012-10-17
          Statement:
            - Action:
                - datazone:*
                - ram:*
                - sso:*
                - kms:*
              Effect: Allow
              Resource: '*'
  example:
    type: aws:datazone:Domain
    properties:
      name: example
      domainExecutionRole: ${domainExecutionRole.arn}

V2 Domain

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

const current = aws.getCallerIdentity({});
// IAM role for Domain Execution
const assumeRoleDomainExecution = current.then(current => aws.iam.getPolicyDocument({
    statements: [{
        conditions: [
            {
                test: "StringEquals",
                values: [current.accountId],
                variable: "aws:SourceAccount",
            },
            {
                test: "ForAllValues:StringLike",
                values: ["datazone*"],
                variable: "aws:TagKeys",
            },
        ],
        principals: [{
            type: "Service",
            identifiers: ["datazone.amazonaws.com"],
        }],
        actions: [
            "sts:AssumeRole",
            "sts:TagSession",
            "sts:SetContext",
        ],
    }],
}));
const domainExecution = new aws.iam.Role("domain_execution", {
    assumeRolePolicy: assumeRoleDomainExecution.then(assumeRoleDomainExecution => assumeRoleDomainExecution.json),
    name: "example-domain-execution-role",
});
const domainExecutionRole = aws.iam.getPolicy({
    name: "SageMakerStudioDomainExecutionRolePolicy",
});
const domainExecutionRolePolicyAttachment = new aws.iam.RolePolicyAttachment("domain_execution", {
    policyArn: domainExecutionRole.then(domainExecutionRole => domainExecutionRole.arn),
    role: domainExecution.name,
});
// IAM role for Domain Service
const assumeRoleDomainService = current.then(current => aws.iam.getPolicyDocument({
    statements: [{
        conditions: [{
            test: "StringEquals",
            values: [current.accountId],
            variable: "aws:SourceAccount",
        }],
        principals: [{
            type: "Service",
            identifiers: ["datazone.amazonaws.com"],
        }],
        actions: ["sts:AssumeRole"],
    }],
}));
const domainService = new aws.iam.Role("domain_service", {
    assumeRolePolicy: assumeRoleDomainService.then(assumeRoleDomainService => assumeRoleDomainService.json),
    name: "example-domain-service-role",
});
const domainServiceRole = aws.iam.getPolicy({
    name: "SageMakerStudioDomainServiceRolePolicy",
});
const domainServiceRolePolicyAttachment = new aws.iam.RolePolicyAttachment("domain_service", {
    policyArn: domainServiceRole.then(domainServiceRole => domainServiceRole.arn),
    role: domainService.name,
});
// DataZone Domain V2
const example = new aws.datazone.Domain("example", {
    name: "example-domain",
    domainExecutionRole: domainExecution.arn,
    domainVersion: "V2",
    serviceRole: domainService.arn,
});
import pulumi
import pulumi_aws as aws

current = aws.get_caller_identity()
# IAM role for Domain Execution
assume_role_domain_execution = aws.iam.get_policy_document(statements=[{
    "conditions": [
        {
            "test": "StringEquals",
            "values": [current.account_id],
            "variable": "aws:SourceAccount",
        },
        {
            "test": "ForAllValues:StringLike",
            "values": ["datazone*"],
            "variable": "aws:TagKeys",
        },
    ],
    "principals": [{
        "type": "Service",
        "identifiers": ["datazone.amazonaws.com"],
    }],
    "actions": [
        "sts:AssumeRole",
        "sts:TagSession",
        "sts:SetContext",
    ],
}])
domain_execution = aws.iam.Role("domain_execution",
    assume_role_policy=assume_role_domain_execution.json,
    name="example-domain-execution-role")
domain_execution_role = aws.iam.get_policy(name="SageMakerStudioDomainExecutionRolePolicy")
domain_execution_role_policy_attachment = aws.iam.RolePolicyAttachment("domain_execution",
    policy_arn=domain_execution_role.arn,
    role=domain_execution.name)
# IAM role for Domain Service
assume_role_domain_service = aws.iam.get_policy_document(statements=[{
    "conditions": [{
        "test": "StringEquals",
        "values": [current.account_id],
        "variable": "aws:SourceAccount",
    }],
    "principals": [{
        "type": "Service",
        "identifiers": ["datazone.amazonaws.com"],
    }],
    "actions": ["sts:AssumeRole"],
}])
domain_service = aws.iam.Role("domain_service",
    assume_role_policy=assume_role_domain_service.json,
    name="example-domain-service-role")
domain_service_role = aws.iam.get_policy(name="SageMakerStudioDomainServiceRolePolicy")
domain_service_role_policy_attachment = aws.iam.RolePolicyAttachment("domain_service",
    policy_arn=domain_service_role.arn,
    role=domain_service.name)
# DataZone Domain V2
example = aws.datazone.Domain("example",
    name="example-domain",
    domain_execution_role=domain_execution.arn,
    domain_version="V2",
    service_role=domain_service.arn)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var current = Aws.GetCallerIdentity.Invoke();

    // IAM role for Domain Execution
    var assumeRoleDomainExecution = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Conditions = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
                    {
                        Test = "StringEquals",
                        Values = new[]
                        {
                            current.Apply(getCallerIdentityResult => getCallerIdentityResult.AccountId),
                        },
                        Variable = "aws:SourceAccount",
                    },
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
                    {
                        Test = "ForAllValues:StringLike",
                        Values = new[]
                        {
                            "datazone*",
                        },
                        Variable = "aws:TagKeys",
                    },
                },
                Principals = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                    {
                        Type = "Service",
                        Identifiers = new[]
                        {
                            "datazone.amazonaws.com",
                        },
                    },
                },
                Actions = new[]
                {
                    "sts:AssumeRole",
                    "sts:TagSession",
                    "sts:SetContext",
                },
            },
        },
    });

    var domainExecution = new Aws.Iam.Role("domain_execution", new()
    {
        AssumeRolePolicy = assumeRoleDomainExecution.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
        Name = "example-domain-execution-role",
    });

    var domainExecutionRole = Aws.Iam.GetPolicy.Invoke(new()
    {
        Name = "SageMakerStudioDomainExecutionRolePolicy",
    });

    var domainExecutionRolePolicyAttachment = new Aws.Iam.RolePolicyAttachment("domain_execution", new()
    {
        PolicyArn = domainExecutionRole.Apply(getPolicyResult => getPolicyResult.Arn),
        Role = domainExecution.Name,
    });

    // IAM role for Domain Service
    var assumeRoleDomainService = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Conditions = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
                    {
                        Test = "StringEquals",
                        Values = new[]
                        {
                            current.Apply(getCallerIdentityResult => getCallerIdentityResult.AccountId),
                        },
                        Variable = "aws:SourceAccount",
                    },
                },
                Principals = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                    {
                        Type = "Service",
                        Identifiers = new[]
                        {
                            "datazone.amazonaws.com",
                        },
                    },
                },
                Actions = new[]
                {
                    "sts:AssumeRole",
                },
            },
        },
    });

    var domainService = new Aws.Iam.Role("domain_service", new()
    {
        AssumeRolePolicy = assumeRoleDomainService.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
        Name = "example-domain-service-role",
    });

    var domainServiceRole = Aws.Iam.GetPolicy.Invoke(new()
    {
        Name = "SageMakerStudioDomainServiceRolePolicy",
    });

    var domainServiceRolePolicyAttachment = new Aws.Iam.RolePolicyAttachment("domain_service", new()
    {
        PolicyArn = domainServiceRole.Apply(getPolicyResult => getPolicyResult.Arn),
        Role = domainService.Name,
    });

    // DataZone Domain V2
    var example = new Aws.DataZone.Domain("example", new()
    {
        Name = "example-domain",
        DomainExecutionRole = domainExecution.Arn,
        DomainVersion = "V2",
        ServiceRole = domainService.Arn,
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/datazone"
	"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 {
		current, err := aws.GetCallerIdentity(ctx, &aws.GetCallerIdentityArgs{}, nil)
		if err != nil {
			return err
		}
		// IAM role for Domain Execution
		assumeRoleDomainExecution, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
			Statements: []iam.GetPolicyDocumentStatement{
				{
					Conditions: []iam.GetPolicyDocumentStatementCondition{
						{
							Test: "StringEquals",
							Values: pulumi.StringArray{
								current.AccountId,
							},
							Variable: "aws:SourceAccount",
						},
						{
							Test: "ForAllValues:StringLike",
							Values: []string{
								"datazone*",
							},
							Variable: "aws:TagKeys",
						},
					},
					Principals: []iam.GetPolicyDocumentStatementPrincipal{
						{
							Type: "Service",
							Identifiers: []string{
								"datazone.amazonaws.com",
							},
						},
					},
					Actions: []string{
						"sts:AssumeRole",
						"sts:TagSession",
						"sts:SetContext",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		domainExecution, err := iam.NewRole(ctx, "domain_execution", &iam.RoleArgs{
			AssumeRolePolicy: pulumi.String(assumeRoleDomainExecution.Json),
			Name:             pulumi.String("example-domain-execution-role"),
		})
		if err != nil {
			return err
		}
		domainExecutionRole, err := iam.LookupPolicy(ctx, &iam.LookupPolicyArgs{
			Name: pulumi.StringRef("SageMakerStudioDomainExecutionRolePolicy"),
		}, nil)
		if err != nil {
			return err
		}
		_, err = iam.NewRolePolicyAttachment(ctx, "domain_execution", &iam.RolePolicyAttachmentArgs{
			PolicyArn: pulumi.String(domainExecutionRole.Arn),
			Role:      domainExecution.Name,
		})
		if err != nil {
			return err
		}
		// IAM role for Domain Service
		assumeRoleDomainService, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
			Statements: []iam.GetPolicyDocumentStatement{
				{
					Conditions: []iam.GetPolicyDocumentStatementCondition{
						{
							Test: "StringEquals",
							Values: pulumi.StringArray{
								current.AccountId,
							},
							Variable: "aws:SourceAccount",
						},
					},
					Principals: []iam.GetPolicyDocumentStatementPrincipal{
						{
							Type: "Service",
							Identifiers: []string{
								"datazone.amazonaws.com",
							},
						},
					},
					Actions: []string{
						"sts:AssumeRole",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		domainService, err := iam.NewRole(ctx, "domain_service", &iam.RoleArgs{
			AssumeRolePolicy: pulumi.String(assumeRoleDomainService.Json),
			Name:             pulumi.String("example-domain-service-role"),
		})
		if err != nil {
			return err
		}
		domainServiceRole, err := iam.LookupPolicy(ctx, &iam.LookupPolicyArgs{
			Name: pulumi.StringRef("SageMakerStudioDomainServiceRolePolicy"),
		}, nil)
		if err != nil {
			return err
		}
		_, err = iam.NewRolePolicyAttachment(ctx, "domain_service", &iam.RolePolicyAttachmentArgs{
			PolicyArn: pulumi.String(domainServiceRole.Arn),
			Role:      domainService.Name,
		})
		if err != nil {
			return err
		}
		// DataZone Domain V2
		_, err = datazone.NewDomain(ctx, "example", &datazone.DomainArgs{
			Name:                pulumi.String("example-domain"),
			DomainExecutionRole: domainExecution.Arn,
			DomainVersion:       pulumi.String("V2"),
			ServiceRole:         domainService.Arn,
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

data "aws_getcalleridentity" "current" {
}
data "aws_iam_getpolicydocument" "assumeRoleDomainExecution" {
  statements {
    conditions {
      test     = "StringEquals"
      values   = [data.aws_getcalleridentity.current.account_id]
      variable = "aws:SourceAccount"
    }
    conditions {
      test     = "ForAllValues:StringLike"
      values   = ["datazone*"]
      variable = "aws:TagKeys"
    }
    principals {
      type        = "Service"
      identifiers = ["datazone.amazonaws.com"]
    }
    actions = ["sts:AssumeRole", "sts:TagSession", "sts:SetContext"]
  }
}
data "aws_iam_getpolicy" "domainExecutionRole" {
  name = "SageMakerStudioDomainExecutionRolePolicy"
}
data "aws_iam_getpolicydocument" "assumeRoleDomainService" {
  statements {
    conditions {
      test     = "StringEquals"
      values   = [data.aws_getcalleridentity.current.account_id]
      variable = "aws:SourceAccount"
    }
    principals {
      type        = "Service"
      identifiers = ["datazone.amazonaws.com"]
    }
    actions = ["sts:AssumeRole"]
  }
}
data "aws_iam_getpolicy" "domainServiceRole" {
  name = "SageMakerStudioDomainServiceRolePolicy"
}

resource "aws_iam_role" "domain_execution" {
  assume_role_policy = data.aws_iam_getpolicydocument.assumeRoleDomainExecution.json
  name               = "example-domain-execution-role"
}
resource "aws_iam_rolepolicyattachment" "domain_execution" {
  policy_arn = data.aws_iam_getpolicy.domainExecutionRole.arn
  role       = aws_iam_role.domain_execution.name
}
resource "aws_iam_role" "domain_service" {
  assume_role_policy = data.aws_iam_getpolicydocument.assumeRoleDomainService.json
  name               = "example-domain-service-role"
}
resource "aws_iam_rolepolicyattachment" "domain_service" {
  policy_arn = data.aws_iam_getpolicy.domainServiceRole.arn
  role       = aws_iam_role.domain_service.name
}
# DataZone Domain V2
resource "aws_datazone_domain" "example" {
  name                  = "example-domain"
  domain_execution_role = aws_iam_role.domain_execution.arn
  domain_version        = "V2"
  service_role          = aws_iam_role.domain_service.arn
}
# IAM role for Domain Execution
# IAM role for Domain Service
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.AwsFunctions;
import com.pulumi.aws.inputs.GetCallerIdentityArgs;
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.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import com.pulumi.aws.iam.inputs.GetPolicyArgs;
import com.pulumi.aws.iam.RolePolicyAttachment;
import com.pulumi.aws.iam.RolePolicyAttachmentArgs;
import com.pulumi.aws.datazone.Domain;
import com.pulumi.aws.datazone.DomainArgs;
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) {
        final var current = AwsFunctions.getCallerIdentity(GetCallerIdentityArgs.builder()
            .build());

        // IAM role for Domain Execution
        final var assumeRoleDomainExecution = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .conditions(
                    GetPolicyDocumentStatementConditionArgs.builder()
                        .test("StringEquals")
                        .values(current.accountId())
                        .variable("aws:SourceAccount")
                        .build(),
                    GetPolicyDocumentStatementConditionArgs.builder()
                        .test("ForAllValues:StringLike")
                        .values("datazone*")
                        .variable("aws:TagKeys")
                        .build())
                .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                    .type("Service")
                    .identifiers("datazone.amazonaws.com")
                    .build())
                .actions(
                    "sts:AssumeRole",
                    "sts:TagSession",
                    "sts:SetContext")
                .build())
            .build());

        var domainExecution = new Role("domainExecution", RoleArgs.builder()
            .assumeRolePolicy(assumeRoleDomainExecution.json())
            .name("example-domain-execution-role")
            .build());

        final var domainExecutionRole = IamFunctions.getPolicy(GetPolicyArgs.builder()
            .name("SageMakerStudioDomainExecutionRolePolicy")
            .build());

        var domainExecutionRolePolicyAttachment = new RolePolicyAttachment("domainExecutionRolePolicyAttachment", RolePolicyAttachmentArgs.builder()
            .policyArn(domainExecutionRole.arn())
            .role(domainExecution.name())
            .build());

        // IAM role for Domain Service
        final var assumeRoleDomainService = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .conditions(GetPolicyDocumentStatementConditionArgs.builder()
                    .test("StringEquals")
                    .values(current.accountId())
                    .variable("aws:SourceAccount")
                    .build())
                .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                    .type("Service")
                    .identifiers("datazone.amazonaws.com")
                    .build())
                .actions("sts:AssumeRole")
                .build())
            .build());

        var domainService = new Role("domainService", RoleArgs.builder()
            .assumeRolePolicy(assumeRoleDomainService.json())
            .name("example-domain-service-role")
            .build());

        final var domainServiceRole = IamFunctions.getPolicy(GetPolicyArgs.builder()
            .name("SageMakerStudioDomainServiceRolePolicy")
            .build());

        var domainServiceRolePolicyAttachment = new RolePolicyAttachment("domainServiceRolePolicyAttachment", RolePolicyAttachmentArgs.builder()
            .policyArn(domainServiceRole.arn())
            .role(domainService.name())
            .build());

        // DataZone Domain V2
        var example = new Domain("example", DomainArgs.builder()
            .name("example-domain")
            .domainExecutionRole(domainExecution.arn())
            .domainVersion("V2")
            .serviceRole(domainService.arn())
            .build());

    }
}
resources:
  domainExecution:
    type: aws:iam:Role
    name: domain_execution
    properties:
      assumeRolePolicy: ${assumeRoleDomainExecution.json}
      name: example-domain-execution-role
  domainExecutionRolePolicyAttachment:
    type: aws:iam:RolePolicyAttachment
    name: domain_execution
    properties:
      policyArn: ${domainExecutionRole.arn}
      role: ${domainExecution.name}
  domainService:
    type: aws:iam:Role
    name: domain_service
    properties:
      assumeRolePolicy: ${assumeRoleDomainService.json}
      name: example-domain-service-role
  domainServiceRolePolicyAttachment:
    type: aws:iam:RolePolicyAttachment
    name: domain_service
    properties:
      policyArn: ${domainServiceRole.arn}
      role: ${domainService.name}
  # DataZone Domain V2
  example:
    type: aws:datazone:Domain
    properties:
      name: example-domain
      domainExecutionRole: ${domainExecution.arn}
      domainVersion: V2
      serviceRole: ${domainService.arn}
variables:
  current:
    fn::invoke:
      function: aws:getCallerIdentity
      arguments: {}
  # IAM role for Domain Execution
  assumeRoleDomainExecution:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        statements:
          - conditions:
              - test: StringEquals
                values:
                  - ${current.accountId}
                variable: aws:SourceAccount
              - test: ForAllValues:StringLike
                values:
                  - datazone*
                variable: aws:TagKeys
            principals:
              - type: Service
                identifiers:
                  - datazone.amazonaws.com
            actions:
              - sts:AssumeRole
              - sts:TagSession
              - sts:SetContext
  domainExecutionRole:
    fn::invoke:
      function: aws:iam:getPolicy
      arguments:
        name: SageMakerStudioDomainExecutionRolePolicy
  # IAM role for Domain Service
  assumeRoleDomainService:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        statements:
          - conditions:
              - test: StringEquals
                values:
                  - ${current.accountId}
                variable: aws:SourceAccount
            principals:
              - type: Service
                identifiers:
                  - datazone.amazonaws.com
            actions:
              - sts:AssumeRole
  domainServiceRole:
    fn::invoke:
      function: aws:iam:getPolicy
      arguments:
        name: SageMakerStudioDomainServiceRolePolicy

Import

Identity Schema

Required

  • id - (String) ID of the DataZone domain.

Optional

  • accountId (String) AWS Account where this resource is managed.
  • region (String) Region where this resource is managed.

Using pulumi import, import DataZone Domain using the domainId. For example:

$ pulumi import aws:datazone/domain:Domain example domain-id-12345678

Constructors

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

Properties

arn ↔ Output<String>
ARN of the Domain.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
description ↔ Output<String?>
Description of the Domain.
latefinal
domainExecutionRole ↔ Output<String>
ARN of the role used by DataZone to configure the Domain.
latefinal
domainVersion ↔ Output<String>
Version of the Domain. Valid values are V1 and V2. Defaults to V1.
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
kmsKeyIdentifier ↔ Output<String?>
ARN of the KMS key used to encrypt the Amazon DataZone domain, metadata and reporting data.
latefinal
name ↔ Output<String>
Name of the Domain.
latefinal
portalUrl ↔ Output<String>
URL of the data portal for the Domain.
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
rootDomainUnitId ↔ Output<String>
ID of the root domain unit.
latefinal
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
serviceRole ↔ Output<String?>
ARN of the service role used by DataZone. Required when domainVersion is set to V2.
latefinal
singleSignOn ↔ Output<DomainSingleSignOn?>
Single sign on options, used to enable AWS IAM Identity Center for DataZone.
latefinal
skipDeletionCheck ↔ Output<bool?>
Whether to skip the deletion check for the Domain.
latefinal
tags ↔ Output<Map<String, String>?>
latefinal
tagsAll ↔ Output<Map<String, String>>
Map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
latefinal
timeouts ↔ Output<DomainTimeouts?>
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, {DomainState? state, CustomResourceOptions? options}) → Domain
Gets an existing Domain resource's state with the given name and id.