

• AWS Systems Manager CloudWatch ダッシュボードは、2026 年 4 月 30 日以降は利用できなくなります。お客様は、これまでと同様に Amazon CloudWatch コンソールを使用して、Amazon CloudWatch ダッシュボードの表示、作成、管理を継続できます。詳細については、「[Amazon CloudWatch ダッシュボードのドキュメント](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html)」を参照してください。

# 自動承認ポリシーとアクセス拒否ポリシーのステートメントの構造とビルトイン演算子
<a name="auto-approval-deny-access-policy-statement-structure"></a>

次の表は、自動承認ポリシーとアクセス拒否ポリシーの構造を示しています。


| コンポーネント | 構文 | 
| --- | --- | 
| effect |  `permit \| forbid`  | 
| scope |  `(principal, action, resource)`  | 
| 条件句 |  <pre>when {<br />    principal or resource has attribute name             <br />};</pre>  | 

## ポリシーの構成要素
<a name="policy-components"></a>

自動承認ポリシーまたはアクセス拒否ポリシーには、次のコンポーネントが含まれます。
+ **効果** - アクセスの `permit` (許可) または `forbid` (拒否)。
+ **スコープ** - 効果を適用するプリンシパル、アクション、リソース。特定のプリンシパル、アクション、リソースを指定しないでおくと、Cedar のスコープを未定義のままにすることができます。この場合、ポリシーはすべてのプリンシパル、アクション、リソースに適用されます。ジャストインタイムノードアクセスの場合、`action` は常に `AWS::SSM::Action::"getTokenForInstanceAccess"` です。
+ **条件句** - 効果が適用されるコンテキスト。

## コメント
<a name="auth-policies-policy-comments"></a>

 ポリシーにコメントを含めることができます。コメントは、`//` で始まり改行文字で終わる行として定義されます。

以下の例は、ポリシー内のコメントを示しています。

```
// Allows users in the Engineering group from the Platform org to automatically connect to nodes tagged with Engineering and Production keys. 
permit (
    principal in AWS::IdentityStore::Group::"d4q81745-r081-7079-d789-14da1EXAMPLE",
    action == AWS::SSM::Action::"getTokenForInstanceAccess",
    resource
)
when {
    principal has organization && resource.hasTag("Engineering") && resource.hasTag("Production") && principal.organization == "Platform"
};
```

## 複数の句
<a name="multiple-clauses"></a>

`&&` 演算子を使用すると、1 つのポリシーステートメントに複数の条件句を含めることができます。

```
// Allow access if node has tag where the tag key is Environment 
// & tag value is Development 

permit(principal, action == AWS::SSM::getTokenForInstanceAccess, resource)
when {
    resource.hasTag("Environment") &&
    resource.getTag("Environment") == "Development"
};
```

## 予約文字
<a name="reserved-characters"></a>

次の例は、コンテキストのプロパティでポリシー言語の予約文字である `:` (セミコロン) が使用されている場合のポリシーの記述方法を示しています。

```
permit (
    principal,
    action == AWS::SSM::Action::"getTokenForInstanceAccess",
    resource
)
when {
    principal has employeeNumber && principal.employeeNumber like "E-1*" && resource.hasTag("Purpose") && resource.getTag("Purpose") == "Testing"
}
```

その他の例については、「[ポリシーステートメントの例](#policy-statement-examples)」を参照してください。

## ジャストインタイムノードアクセスのスキーマ
<a name="auto-approval-deny-access-policy-statement-schema"></a>

以下は、ジャストインタイムノードアクセス用の Cedar スキーマです。

```
namespace AWS::EC2 {
    entity Instance tags String;
}


namespace AWS::IdentityStore {
    entity Group;
    
    entity User in [Group] {
    employeeNumber?: String,
    costCenter?: String,
    organization?: String,
    division?: String,
    };

}


namespace AWS::IAM {

    entity Role;
    
    type AuthorizationContext = {
        principalTags: PrincipalTags,
    };
    
    entity PrincipalTags tags String;
}

namespace AWS::SSM {

    entity ManagedInstance tags String;

    action "getTokenForInstanceAccess" appliesTo {
    principal: [AWS::IdentityStore::User],
    resource: [AWS::EC2::Instance, AWS::SSM::ManagedInstance],
    context: {
        "iam": AWS::IAM::AuthorizationContext
        }
    };
}
```

## ビルトイン演算子
<a name="built-in-policy-operators"></a>

さまざまな条件を使用して自動承認ポリシーまたはアクセス拒否ポリシーのコンテキストを作成する場合は、`&&` 演算子を使用して追加条件を指定できます。ポリシー条件にさらに表現力を加えるために使用できるビルトイン演算子は他にも多数あります。参照用にすべてのビルトイン演算子を下表に示します。

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/systems-manager/latest/userguide/auto-approval-deny-access-policy-statement-structure.html)

## ポリシーステートメントの例
<a name="policy-statement-examples"></a>

ポリシーステートメントの例を以下に示します。

```
// Users assuming IAM roles with a principal tag of "Elevated" can automatically access nodes tagged with the "Environment" key when the value equals "prod"
permit(principal, action == AWS::SSM::getTokenForInstanceAccess, resource)
when {
    // Verify IAM role principal tag
    context.iam.principalTags.getTag("AccessLevel") == "Elevated" &&
    
    // Verify the node has a tag with "Environment" tag key and a tag value of "prod"
    resource.hasTag("Environment") &&
    resource.getTag("Environment") == "prod"
};
```

```
// Identity Center users in the "Contractor" division can automatically access nodes tagged with the "Environment" key when the value equals "dev"
permit(principal, action == AWS::SSM::getTokenForInstanceAccess, resource)
when {
    // Verify that the user is part of the "Contractor" division
    principal.division == "Contractor" &&
    
    // Verify the node has a tag with "Environment" tag key and a tag value of "dev"
    resource.hasTag("Environment") &&
    resource.getTag("Environment") == "dev"
};
```

```
// Identity Center users in a specified group can automatically access nodes tagged with the "Environment" key when the value equals "Production"
permit(principal in AWS::IdentityStore::Group::"d4q81745-r081-7079-d789-14da1EXAMPLE",
    action == AWS::SSM::getTokenForInstanceAccess,
    resource)
when {
    resource.hasTag("Environment") &&
    resource.getTag("Environment") == "Production"
};
```