# IAM

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

---

The IAM sample template creates roles, policies, users, and groups.

> **Reference**: If the template includes a configuration that creates IAM resources, you must select the **Approve to allow the Infrastructure Builder to create IAM resources.** item in the **Parameter Settings** step for the **Next** button to become active. For more details, refer to [스택 생성하기](/en/userguide/management/infrastructure_builder/how_to_guides/#create).

# Create a user and add it to a group {#user-group}

Create users and groups, and add the created users to the created groups.

* **AccountId**, **UserName**, **UserPassword** are required.
* **UserPassword** is displayed with the input value masked (NoEcho). Do not write the password directly in the template; instead, provide it as a parameter when creating the stack.
* **TemporaryPassword** is set to `true`, and it is recommended to change the password after the first login.
* Changing **UserName** will replace the user resource.


```yaml
SCPTemplateFormatVersion: '2026-01-01'
Description: 'IAM user/group creation and group enrollment sample'

Parameters:
  AccountId:
    Type: String
    Description: 'Account ID for creating the user'
  UserName:
    Type: String
    Description: 'User name (resource replacement when changed)'
  UserPassword:
    Type: String
    NoEcho: true
    Description: 'User password (change recommended after first login)'
  GroupName:
    Type: String
    Default: example-group
    Description: 'Group name (3~24 characters)'

Resources:
  ExampleGroup:
    Type: SCP::IAM::Group
    Properties:
      Name: !Ref GroupName
      Description: 'Example Group'
      UserIds:
        - !Ref ExampleUser
  ExampleUser:
    Type: SCP::IAM::User
    Properties:
      AccountId: !Ref AccountId
      UserName: !Ref UserName
      TemporaryPassword: true
      Password: !Ref UserPassword
      Description: 'Example User'

Outputs:
  UserId:
    Description: 'ID of the created user'
    Value: !Ref ExampleUser
  GroupId:
    Description: 'ID of the created group'
    Value: !Ref ExampleGroup
```

_Code block. Template for creating a user and adding to a group_

# Create a policy and attach it to groups and roles {#policy-attach}

Create a policy and attach it to groups and roles.

* **GroupName**, **RoleName**, **TrustedAccountId** are required.
* In **TrustedAccountId**, enter the Account ID that will receive the delegated role.


```yaml
SCPTemplateFormatVersion: '2026-01-01'
Description: 'IAM policy creation and group/role association sample'

Parameters:
  PolicyName:
    Type: String
    Default: example-policy
    Description: 'Policy name (3~128 characters)'
  GroupName:
    Type: String
    Description: 'Group name to assign the policy (3~24 characters)'
  RoleName:
    Type: String
    Description: 'Role name to which the policy will be granted (1~64 characters)'
  TrustedAccountId:
    Type: String
    Description: 'Account ID to assume the role'

Resources:
  ExamplePolicy:
    Type: SCP::IAM::Policy
    Properties:
      PolicyName: !Ref PolicyName
      Description: 'Example Policy'
      PolicyVersion:
        PolicyVersionName: POLICY_VERSION_1
        PolicyDocument:
          Version: '2024-07-01'
          Statement:
            - Sid: ReadOnly
              Effect: Allow
              Action:
                - 'iam:Get*'
              Resource:
                - *
  ExampleGroup:
    Type: SCP::IAM::Group
    Properties:
      Name: !Ref GroupName
      Description: 'Group with attached policy'
      PolicyIds:
        - !Ref ExamplePolicy
  ExampleRole:
    Type: SCP::IAM::Role
    Properties:
      Name: !Ref RoleName
      Description: 'Roles attached to the policy'
      PolicyIds:
        - !Ref ExamplePolicy
      Principals:
        - Type: ACCOUNT
          Value: !Ref TrustedAccountId

Outputs:
  PolicyId:
    Description: 'ID of the generated policy'
    Value: !Ref ExamplePolicy
```

_Code block. Create a policy and attach it to groups and roles template_

# Object Storage bucket read-only role {#object-storage-read}

Create a read‑only policy for an existing Object Storage bucket and create a role that is granted this policy.

* **BucketSrn**, **TrustedAccountId** are required.
* In **BucketSrn**, enter the SRN of the bucket to grant read permission in the format `srn:<환경>::<계정ID>:<리전>::objectstorage:bucket/<버킷이름>`.
* The policy allows bucket listing, information retrieval, and object download operations.


```yaml
SCPTemplateFormatVersion: '2026-01-01'
Description: 'Object Storage read-only policy and role creation sample'

Parameters:
  PolicyName:
    Type: String
    Default: ObjectStorageReadOnlyPolicy
    Description: 'Policy name (3~128 characters)'
  RoleName:
    Type: String
    Default: ObjectStorageReadRole
    Description: 'Role name (1~64 characters)'
  BucketSrn:
    Type: String
    Description: 'Bucket SRN to grant read permission (format: srn:<환경>::<계정ID>:<리전>::objectstorage:bucket/<버킷이름>)'
  TrustedAccountId:
    Type: String
    Description: 'Account ID to assume the role'

Resources:
  ReadOnlyPolicy:
    Type: SCP::IAM::Policy
    Properties:
      PolicyName: !Ref PolicyName
      Description: 'Read-only permission for a specific bucket'
      PolicyVersion:
        PolicyVersionName: POLICY_VERSION_1
        PolicyDocument:
          Version: '2024-07-01'
          Statement:
            - Sid: ReadBucket
              Effect: Allow
              Action:
                - 'objectstorage:List*'
                - 'objectstorage:Show*'
                - objectstorage:DownloadBucketObject
              Resource:
                - !Ref BucketSrn
  ReadOnlyRole:
    Type: SCP::IAM::Role
    Properties:
      Name: !Ref RoleName
      Description: 'Bucket read-only role'
      PolicyIds:
        - !Ref ReadOnlyPolicy
      Principals:
        - Type: ACCOUNT
          Value: !Ref TrustedAccountId

Outputs:
  PolicyIdOutput:
    Description: 'Generated policy ID'
    Value: !Ref ReadOnlyPolicy
  RoleIdOutput:
    Description: 'ID of the created role'
    Value: !Ref ReadOnlyRole
```

_Code block. Object Storage bucket read‑only role template_

# ServiceWatch log integration role {#servicewatch-log-role}

Create a role to forward each account’s audit logs and system logs to ServiceWatch.

* All parameters have default values, so there are no required parameters to input.


```yaml
SCPTemplateFormatVersion: '2026-01-01'
Description: 'ServiceWatch log collection role sample'

Parameters:
  RoleName:
    Type: String
    Default: ServiceRoleForServiceWatchLogCollection
    Description: 'Enter the role name.' (1~64 characters)
  PolicyName:
    Type: String
    Default: servicewatch-log-collection-policy
    Description: 'Enter the policy name.' (3~128 characters)

Resources:
  ServiceWatchLogPolicy:
    Type: SCP::IAM::Policy
    Properties:
      PolicyName: !Ref PolicyName
      Description: 'ServiceWatch log collection and transmission permission'
      PolicyVersion:
        PolicyVersionName: POLICY_VERSION_1
        PolicyDocument:
          Version: '2024-07-01'
          Statement:
            - Sid: SendLogsToServiceWatch
              Effect: Allow
              Action:
                - servicewatch:CollectLogGroupLogStream
                - 'servicewatch:CreateBulkServiceLogEvents'
              Resource:
                - *
  ServiceWatchLogRole:
    Type: SCP::IAM::Role
    Properties:
      Name: !Ref RoleName
      Description: 'ServiceWatch log integration role'
      PolicyIds:
        - !Ref ServiceWatchLogPolicy
      Principals:
        - Type: SERVICE
          Value: loggingaudit.samsungsdscloud.com

Outputs:
  PolicyIdOutput:
    Description: 'ID of the generated policy'
    Value: !Ref ServiceWatchLogPolicy
  RoleIdOutput:
    Description: 'ID of the created role'
    Value: !Ref ServiceWatchLogRole
```

_Code block. ServiceWatch log integration role template_

# ServiceWatch Cross Account role {#servicewatch-cross-account-role}

ServiceWatch creates a role that delegates permission to share the target account’s metrics and dashboards with the monitoring account.

* **MonitoringAccountId** is required. Enter the monitoring Account ID to receive shared metrics and dashboards.
* **ServiceWatch-CrossAccountSharingPolicy** is already created as a default policy, so creating a policy with the same name may cause a conflict. Use a different name for **PolicyName**. The default is `CustomServiceWatchCrossAccountSharingPolicy`.


```yaml
SCPTemplateFormatVersion: '2026-01-01'
Description: 'ServiceWatch Cross Account Shared Role Sample'

Parameters:
  RoleName:
    Type: String
    Default: ServiceWatch-CrossAccountSharingRole
    Description: 'Enter the role name.'
  PolicyName:
    Type: String
    Default: CustomServiceWatchCrossAccountSharingPolicy
    Description: 'Enter the policy name.' (3~128 characters)
  MonitoringAccountId:
    Type: String
    Description: 'Monitoring Account ID to receive shared metrics and dashboards'

Resources:
  CrossAccountSharingPolicy:
    Type: SCP::IAM::Policy
    Properties:
      PolicyName: !Ref PolicyName
      Description: 'ServiceWatch view permission to be shared with the Monitoring account'
      PolicyVersion:
        PolicyVersionName: POLICY_VERSION_1
        PolicyDocument:
          Version: '2024-07-01'
          Statement:
            - Sid: ShareServiceWatch
              Effect: Allow
              Action:
                - servicewatch:ListDashboards
                - 'servicewatch:ShowDashboard'
                - servicewatch:ListSearchOptions
                - servicewatch:ListSearchOptionTags
                - servicewatch:ListMetricInfos
                - servicewatch:ListMetricSeries
                - 'servicewatch:ListDimensionValues'
                - servicewatch:ListDimensionColumns
                - 'servicewatch:ListKeyMetrics'
                - 'servicewatch:ListMetricData'
                - 'servicewatch:ShowMetricDataJson'
                - servicewatch:DownloadMetricDataCsv
                - servicewatch:DownloadMetricDataImage
                - 'servicewatch:ExportMetricData'
                - 'servicewatch:ListMetricComparePeriods'
                - 'servicewatch:DownloadMetricComparePeriodsCsv'
                - servicewatch:ExportMetricComparePeriods
                - 'resourcemanager:ListResources'
                - 'resourcemanager:ListTags'
              Resource:
                - *
  CrossAccountSharingRole:
    Type: SCP::IAM::Role
    Properties:
      Name: !Ref RoleName
      Description: 'ServiceWatch Cross Account shared role'
      PolicyIds:
        - !Ref CrossAccountSharingPolicy
      Principals:
        - Type: ACCOUNT
          Value: !Ref MonitoringAccountId

Outputs:
  PolicyIdOutput:
    Description: 'Generated policy ID'
    Value: !Ref CrossAccountSharingPolicy
  RoleIdOutput:
    Description: 'Generated role ID'
    Value: !Ref CrossAccountSharingRole
```

_Code block. ServiceWatch Cross Account role template_

# Stack Set Administrator Role (Self Managed) {#stackset-admin-role}

Create the Admin role required when using **Self Managed** as the permission model for a stack set. Configure the stack set service to assume this role and delegate tasks to the Execution role of the target account.

* All parameters have default values, so there are no required parameters to input.
* **ExecutionRoleName** specifies the name of the Execution role to be delegated, and the default is the role name generated by the [스택 세트 실행 역할(Self Managed)](#stackset-execution-role) sample.


```yaml
SCPTemplateFormatVersion: '2026-01-01'
Description: 'Sample Admin role for StackSet Self Managed permissions'

Parameters:
  RoleName:
    Type: String
    Default: SCPInfrastructureBuilderStackSetAdministrationRole
    Description: 'Enter the role name.' (1~64 characters)
  PolicyName:
    Type: String
    Default: stackset-admin-policy
    Description: 'Enter the policy name. (3~128 characters)
  ExecutionRoleName:
    Type: String
    Default: SCPInfrastructureBuilderStackSetExecutionRole
    Description: 'Assume target Execution role name'

Resources:
  StackSetAdminPolicy:
    Type: SCP::IAM::Policy
    Properties:
      PolicyName: !Ref PolicyName
      Description: 'Policy for StackSet to assume the Execution Role'
      PolicyVersion:
        PolicyVersionName: POLICY_VERSION_1
        PolicyDocument:
          Version: '2024-07-01'
          Statement:
            - Sid: AssumeExecutionRole
              Effect: Allow
              Action:
                - 'sts:AssumeRole'
              Resource:
                - *
              Condition:
                StringLike:
                  "scp:RequestAttribute/body['roleIndicator']"
                    - !Sub '*:*:${ExecutionRoleName}*'
  StackSetAdminRole:
    Type: SCP::IAM::Role
    Properties:
      Name: !Ref RoleName
      Description: 'Infrastructure Builder StackSet Self Managed Admin role'
      PolicyIds:
        - !Ref StackSetAdminPolicy
      Principals:
        - Type: SERVICE
          Value: infrastructure-builder.samsungsdscloud.com

Outputs:
  PolicyIdOutput:
    Description: 'Generated policy ID'
    Value: !Ref StackSetAdminPolicy
  RoleIdOutput:
    Description: 'ID of the created role'
    Value: !Ref StackSetAdminRole
```

_Code block. Stack set administrator role (Self Managed) template_

# Stack Set execution role (Self Managed) {#stackset-execution-role}

Create an Execution role that, delegated from the Admin role, actually deploys resources in the target Account. It must be created for each target Account.

* **AdminRoleSrn** is required. Enter the SRN of the trusted Admin role.

> **Caution**: This sample uses a policy that allows all actions (`*`) and all resources (`*`). In production environments, limit the scope to allow only the permissions required for resources deployed with a stack set.


```yaml
SCPTemplateFormatVersion: '2026-01-01'
Description: 'Sample Execution role for StackSet Self Managed permissions'

Parameters:
  RoleName:
    Type: String
    Default: SCPInfrastructureBuilderStackSetExecutionRole
    Description: 'Enter the role name.' (1~64 characters)
  PolicyName:
    Type: String
    Default: stackset-execution-policy
    Description: 'Enter the policy name. (3~128 characters)
  AdminRoleSrn:
    Type: String
    Description: 'Trusted Admin role SRN'

Resources:
  StackSetExecutionPolicy:
    Type: SCP::IAM::Policy
    Properties:
      PolicyName: !Ref PolicyName
      Description: 'Full permission policy required for StackSet deployment'
      PolicyVersion:
        PolicyVersionName: POLICY_VERSION_1
        PolicyDocument:
          Version: '2024-07-01'
          Statement:
            - Sid: FullAccess
              Effect: Allow
              Action:
                - *
              Resource:
                - *
  StackSetExecutionRole:
    Type: SCP::IAM::Role
    Properties:
      Name: !Ref RoleName
      Description: 'Infrastructure Builder StackSet Self Managed Execution role'
      PolicyIds:
        - !Ref StackSetExecutionPolicy
      Principals:
        - Type: SRN
          Value: !Ref AdminRoleSrn

Outputs:
  ExecutionRoleId:
    Description: 'ID of the generated Execution role'
    Value: !Ref StackSetExecutionRole
```

_Code block. Stack set execution role (Self Managed) template_
