createAccessGrant

Creates an AccessGrant that authorizes a principal to perform a set of actions on resources in a space. Optionally narrow the grant with scoped actions that limit it to specific resources and fields. Use ListAccessGrants and GetAccessGrant to retrieve grants, and DeleteAccessGrant to remove them.

Samples

// The following example creates a custom access grant that authorizes an Identity Center user to read
// and update a specific dashboard in a space. Payloads are shown as JSON on the wire they are CBOR
// encoded.
val resp = cloudWatchOmniClient.createAccessGrant {
    domainId = "d-1a2b3c4d5e"
    spaceId = "a1b2c3d4-5e6f-4a3b-8c9d-0e1f2a3b4c5d"
    name = "analyst-read-access"
    principal = AccessGrantPrincipal {
        principalType = AccessGrantPrincipalType.fromValue("IDC_USER")
        principalId = "94b6c7d8-1a2b-4c3d-9e4f-5a6b7c8d9e0f"
    }
    permission = AccessGrantPermission.fromValue("CUSTOM")
    scopedActions = listOf<ScopedActions>(
        ScopedActions {
            actions = listOf<String>(
                "cloudwatch:GetOmniDashboard",
                "cloudwatch:UpdateOmniDashboard"
            )
            resources = listOf<ResourceScope>(
                ResourceScope {
                    resourceType = "OmniDashboard"
                    resourceArns = listOf<String>(
                        "arn:aws:cloudwatch:us-east-1:123456789012:omni-dashboard/c3d4e5f6-7a8b-4c9d-8e0f-1a2b3c4d5e6f"
                    )
                }                    
            )
        }            
    )
    tags = mapOf<String, String>(
        "Team" to "observability"
    )
    clientToken = "3f2a9c1e-7b04-4d8a-9e15-6c2b8d0f4a73"
}