# Stack Set

LLMS index: [llms.txt](https://docs.e.samsungsdscloud.com/en/userguide/management/llms.txt)

---

# Stack Set {#stack-set}

A stack set is a management unit for deploying a single template to multiple accounts and regions. You can create stacks in multiple target accounts with a single operation from the administrator account. For the role of each Account, see [Account roles](#account-role).

Using stack sets, you can standardize infrastructure by applying organization-wide standards, such as security groups, IAM roles, and logging configurations, uniformly across all accounts. You can also configure the system to automatically deploy the default infrastructure whenever a new account is added to a specific organizational unit (OU).

# Stack instance {#stack-instance}

A stack instance is an individual stack that a stack set actually creates in a specific account and region. If a stack set is the blueprint, a stack instance is the execution entity that actually provisions resources in each account and region.

The state of the stack instance is as follows.


| Status | Description |
|---------|--------|
| Pending | No work has started on the specified instance yet. |
| Running | A task is in progress on the specified instance |
| Succeeded | The operation succeeded on the specified instance. |
| Failed | The task failed on the specified instance |
| Import Failed | Failed to retrieve the stack for the specified instance |
| Cancelled | The job was canceled and did not run on the instance because it was aborted or exceeded the failure threshold. |
| Inoperable | The instance deletion operation failed, leaving the stack in an unstable state. |

_Table. Stack instance status_


> **Reference**: To view the details of a stack instance, log in to the account where the stack instance is deployed and then query the stack in the corresponding region.

# Account role {#account-role}

A stack set involves accounts with different roles. Before understanding the permission model, first distinguish the roles of each Account.


| Category | Description |
|---------|--------|
| Admin Account | Account<ul><li> that creates and manages stack sets. </li></ul><ul><li>**Service Managed**: Organization management Account or delegated administrator. </li></ul><ul><li>**Self Managed**: The Account that created the stack set. </li></ul> |
| Target Account | The account where the individual stacks (stack instances) belonging to the stack set are created<ul><li>A stack instance is created for each target account to operate the actual resources</li></ul> |
| Organization Management Account | The account that manages the organization<ul><li>Has administrator access for the Service Managed permission</li></ul> |
| Delegated Administrator | A member account that can create and manage Service Managed stack sets on behalf of the organization management account<ul><li>Shares administrator access for the Service Managed permission, the same as the organization management account</li></ul><ul><li>For details, see [Delegated administrator](#delegated-admin)</li></ul> |
| General Account within the organization | An account that belongs to the organization but is neither the organization management account nor a delegated administrator<ul><li>Cannot create Service Managed stack sets</li></ul> |
| Accounts not belonging to an organization | An account that does not belong to the Organization<ul><li>Can be a deployment target only through **Deploy stack to Account** of the **Self Managed** permission</li></ul><ul><li>Cannot select **Deploy stack to all Accounts in the organizational unit**</li></ul> |

_Table. Account roles associated with stack sets_


The stack sets that can be created vary by account type, as follows:


| Account types | Create a Service Managed stack set | Create a Self-Managed Stack Set |
|---------|--------|--------|
| Organization Management Account | Possible | Possible |
| Delegated Administrator | Possible | Possible |
| General Account within the organization | Not possible | Possible |
| Accounts not belonging to an organization | Not possible | Possible |

_Table. Stack set creation availability by account type_


> **Reference**: If you do not register a delegated administrator, only the organization management account can create Service Managed stack sets.

# Permission Model {#permission}

Stack sets manage permissions for deploying resources to the target account in two ways: Service Managed and Self Managed. The differences between these two permission models are as follows.


| Category | Service Managed permission (SERVICE_MANAGED) | Self Managed permission (SELF_MANAGED) |
|---------|--------|--------|
| IAM Role Management Principal | The Organization manages it on your behalf | Users create and manage directly |
| Deployment Target | Organization or organizational unit (OU) | Individual Account |
| Prerequisites | No need to create a separate IAM role | Create IAM service roles in the administrator account and target accounts first<ul><li>Administrator account: SCPInfrastructureBuilderStackSetAdministrationRole</li></ul><ul><li>Target account: SCPInfrastructureBuilderStackSetExecutionRole</li></ul> |
| Access Control | Use the permission system provided by Organization | Fine-grained control through role permission policies and trust policies |
| Appropriate Environment | Environments that use Organization | Environments that are not Organization-based or require more granular control |

_Table. Comparison of Service Managed and Self Managed_


For the prerequisites for the Self Managed permission, see [Self Managed permission overview](#self-managed).

> **Warning**: After you create a stack set, you cannot change the permission model. Before creating a stack set, determine the deployment target and permission management method.

## Self-Managed Permissions Overview {#self-managed}

Before creating a stack set with the Self Managed permission, you must first create an IAM service role in each account. The basic steps are as follows.

1. Determines the administrator account.
    - The administrator Account is the Account in which the stack set is created.
    - The target account is the account in which individual stacks within a stack set are created.
2. Determine how to structure permissions for stack sets.
    - The simplest and most permissive configuration is to allow all users and groups in the administrator account to create and update all stack sets managed through that account.
    - For more granular control, you can configure permissions by distinguishing the following.
        - Users and groups that can perform stack set operations in the target account
        - Resources that can be included in a stack set
        - Stack set operations that specific users and groups can perform
3. Create the required IAM service roles for the administrator account and the target account to define the desired permissions.
The required roles are as follows:

| Role | Deployment location |
|---------|--------|
| SCPInfrastructureBuilderStackSetAdministrationRole | Admin Account |
| SCPInfrastructureBuilderStackSetExecutionRole | All target accounts that create stack instances |

_Table. Roles required for Self Managed permissions_


## Grant stack management permissions for all target accounts to all users in the administrator account {#self-managed-all-users}

This is a method of configuring permissions so that all users and groups in the administrator Account can perform stack set operations on all target Accounts. All users in the administrator Account can create, update, and delete stacks in all target Accounts.

### Admin Account {#self-managed-admin}

Creates the **SCPInfrastructureBuilderStackSetAdministrationRole** role in the administrator account. This role has the following permission policies and principals.


| Category | Description |
|---------|--------|
| Permission Policy | The permission (`sts:AssumeRole`) to assume the **SCPInfrastructureBuilderStackSetExecutionRole** role for all target accounts |
| Actor | Allow the Infrastructure Builder service to use the administrator role |

_Table. Administrator role policy_


The administrator role includes the following permission policies.


```json
{
  "Version": "2024-07-01",
  "Statement": [
    {
      "Action": [
        "sts:AssumeRole"
      ],
      "Resource": [
        *
      ],
      "Effect": "Allow",
      "Condition": {
        "StringLike": {
          "iam:roleName": ["SCPInfrastructureBuilderStackSetExecutionRole"]
        }
      }
    }
  ]
}
```

_Code block. Example of a permission policy_

Set the principal as follows to allow the service to use the administrator role.


| Category | Value |
|---------|--------|
| Service | infrastructure-builder.samsungsdscloud.com |

_Table. Performer connection_


### Target Account {#self-managed-target}

Creates an **SCPInfrastructureBuilderStackSetExecutionRole** role in each target account that trusts the administrator account. Role names must match exactly. When creating a role, specify the ID of the administrator account that establishes a trust relationship with the target account.

> **Important**: Execution role templates grant administrator access permissions. After creating a role, restrict the permission scope of the policy statement to the resource types that you will create in the stack set.

The service role of the target account requires the permissions to perform the tasks specified in the template. For example, if a template creates an IAM group, you need the permission to create an IAM group. Additionally, full Infrastructure Builder permissions are always required to create, update, delete, and query stacks.


| Category | Description |
|---------|--------|
| Permission Policy | <ul><li>Roles created with the default template allow permissions (`*`) for all actions and resources.</li></ul><ul><li>The minimum permissions required for a stack set to function are `infrastructure-builder:*`.</li></ul><ul><li>For stacks that create service resources other than Infrastructure Builder, add the actions and resources for that service to the policy.</li></ul> |
| Trust Policy | Trust the administrator account to allow `sts:AssumeRole` |

_Table. Execution role policy_


The following policy is applied to roles created with the default template.


```json
{
  "Version": "2024-07-01",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        *
      ],
      "Resource": [
        *
      ]
    }
  ]
}
```

_Code Block. Permission Policy Example 1_

The following policy grants the minimum permissions required for the stack set to function. To create a stack that uses service resources other than Infrastructure Builder, you must add the actions and resources for the corresponding service to the execution role policy in each target account.


```json
{
  "Version": "2024-07-01",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "infrastructure-builder:*"
      ],
      "Resource": [
        *
      ]
    }
  ]
}
```

_Code Block. Permission Policy Example 2_

Set the principal as follows to trust the administrator Account. In the example, `111122223333` is the ID of the administrator Account.


| Category | Value |
|---------|--------|
| Other Account | 111122223333 |

_Table. Example of connecting the performing entity_


# Deployment Options {#deploy}

## Deployment Target {#target}

The deployment target for a stack is specified as follows, depending on the permission model of the stack set.


| Permission Model | Deployment Target Specification |
|---------|--------|
| Service Managed | **Deploy to organization** (default): Deploy to all Accounts in the organization<ul><li>**Deploy to organization units**: Enter up to 50 organization unit IDs</li></ul><ul><li>If a parent organization unit is specified, all child organization units are automatically included in the target</li></ul> |
| Self Managed | **Deploy stack to accounts** (default): Enter up to 50 account IDs<ul><li>**Deploy stack to all accounts in the organization**: Enter one organization ID</li></ul><ul><li>Accounts that are not part of an organization can only select **Deploy stack to accounts**</li></ul> |

_Table. Deployment targets by permission model_


## Automated Deployment {#auto-deploy}

Automatic deployment is available only with the Service Managed permission. When you set the automatic deployment policy to **Enabled**, stack instances are automatically deployed to the Account when it is added to the organization. The handling method when an Account is removed at the organization level (**Account removal behavior**) can be specified as follows.


| Category | Description |
|---------|--------|
| Delete Stack | When an Account is removed from the target organizational unit, delete the stack instances for that Account. |
| Stack storage | Retain the stack instances of the Account even if the Account is removed from the target organizational unit |

_Table. Account removal behavior_


## Region specification {#region}

Select the region to deploy the stack. Stacks are deployed in the specified order.

## Deployment Settings {#concurrency}

You can specify the concurrency level and failure tolerance when deploying to multiple accounts and regions. You can leave maximum concurrency and fault tolerance blank.


| Category | Description |
|---------|--------|
| Maximum concurrent processing | Number of accounts per region for simultaneous stack deployment <ul><li>Specify by number of accounts or percentage </li></ul><ul><li>A larger value increases the job speed </li></ul> |
| Fault tolerance | The number of accounts per region that can fail during deployment before the job is aborted<ul><li>Specify as a number or percentage of accounts</li></ul><ul><li>Lower values are safer. If the job is aborted in one region, it does not proceed to other regions</li></ul> |
| Legion simultaneous deployment | Select the region processing method <ul><li>**Sequential deployment** (default): Deploys to one region at a time in the specified region order </li></ul><ul><li>**Parallel deployment**: Deploys to all specified regions simultaneously </li></ul> |
| Concurrent Execution | Select the concurrency mode during job execution <ul><li>**Strict Fault Tolerance** (default): Dynamically lowers the concurrency level to ensure the number of failed Accounts does not exceed Fault Tolerance + 1. </li></ul><ul><li>**Fault Tolerance**: Always runs at the specified concurrency level. </li></ul> |

_Table. Stack set deployment options_


> **Reference**: Instead of deploying to all Accounts at once, setting a low maximum concurrency and fault tolerance limits the blast radius if an issue occurs in some Accounts.

# Delegated Administrator {#delegated-admin}

A delegated administrator is a member account that can create and manage the Service Managed stack set for the organization. Shares administrator access to Service Managed permissions, just like the Organization Management account.

To register a delegated administrator, the account must belong to the organization. You can register up to five accounts per organization.
