

• AWS Systems Manager CloudWatch Dasbor tidak akan lagi tersedia setelah 30 April 2026. Pelanggan dapat terus menggunakan CloudWatch konsol Amazon untuk melihat, membuat, dan mengelola CloudWatch dasbor Amazon mereka, seperti yang mereka lakukan hari ini. Untuk informasi selengkapnya, lihat [dokumentasi CloudWatch Dasbor Amazon](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html). 

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# Struktur pernyataan dan operator bawaan untuk kebijakan persetujuan otomatis dan akses penolakan
<a name="auto-approval-deny-access-policy-statement-structure"></a>

Tabel berikut menunjukkan struktur kebijakan persetujuan otomatis dan penolakan akses.


| Komponen | Sintaksis | 
| --- | --- | 
| efek |  `permit \| forbid`  | 
| cakupan |  `(principal, action, resource)`  | 
| klausa kondisi |  <pre>when {<br />    principal or resource has attribute name             <br />};</pre>  | 

## Komponen kebijakan
<a name="policy-components"></a>

Kebijakan persetujuan otomatis atau penolakan akses berisi komponen-komponen berikut:
+ **Efek** - Baik `permit` (izinkan) atau `forbid` (tolak) akses.
+ **Lingkup** — Prinsip, tindakan, dan sumber daya yang efeknya berlaku. Anda dapat membiarkan ruang lingkup di Cedar tidak terdefinisi dengan tidak mengidentifikasi prinsip, tindakan, atau sumber daya tertentu. Dalam hal ini, kebijakan berlaku untuk semua prinsip, tindakan, dan sumber daya yang mungkin. Untuk akses just-in-time node, `action` selalu`AWS::SSM::Action::"getTokenForInstanceAccess"`.
+ **Klausul kondisi** — Konteks di mana efek berlaku.

## Komentar
<a name="auth-policies-policy-comments"></a>

Anda dapat memasukkan komentar dalam kebijakan Anda. Komentar didefinisikan sebagai baris yang dimulai dengan `//` dan diakhiri dengan karakter baris baru.

Contoh berikut menunjukkan komentar dalam kebijakan.

```
// 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"
};
```

## Beberapa klausa
<a name="multiple-clauses"></a>

Anda dapat menggunakan lebih dari satu klausa kondisi dalam pernyataan kebijakan menggunakan `&&` operator.

```
// 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"
};
```

## Karakter yang dipesan
<a name="reserved-characters"></a>

Contoh berikut menunjukkan cara menulis kebijakan jika properti context menggunakan `:` (titik koma), yang merupakan karakter cadangan dalam bahasa kebijakan.

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

Untuk contoh tambahan, lihat [Contoh pernyataan kebijakan](#policy-statement-examples).

## Just-in-time skema akses simpul
<a name="auto-approval-deny-access-policy-statement-schema"></a>

Berikut ini adalah skema Cedar untuk akses just-in-time node.

```
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
        }
    };
}
```

## Operator bawaan
<a name="built-in-policy-operators"></a>

Saat membuat konteks kebijakan persetujuan otomatis atau penolakan akses menggunakan berbagai kondisi, Anda dapat menggunakan `&&` operator untuk menambahkan kondisi tambahan. Ada juga banyak operator bawaan lainnya yang dapat Anda gunakan untuk menambahkan kekuatan ekspresif tambahan pada kondisi kebijakan Anda. Tabel berikut berisi semua operator bawaan untuk referensi.

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

## Contoh pernyataan kebijakan
<a name="policy-statement-examples"></a>

Berikut ini adalah contoh pernyataan kebijakan.

```
// 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"
};
```