Resource definition
What this resource looks like
This is the CUE shape a Praxis template uses to declare a IAMPolicy. The resource key is local to the template; metadata.name supplies its stable Praxis identity.
resources: {
appPolicy: {
apiVersion: "praxis.io/alpha"
kind: "IAMPolicy"
metadata: name: "\(_naming.prefix)-app-policy"
spec: {
path: "/app/"
policyDocument: json.Marshal({
Version: "2012-10-17"
Statement: [
{
Sid: "S3Access"
Effect: "Allow"
Action: [
"s3:GetObject",
"s3:PutObject",
"s3:ListBucket",
]
Resource: "*"
},
{
Sid: "SQSAccess"
Effect: "Allow"
Action: [
"sqs:SendMessage",
"sqs:ReceiveMessage",
"sqs:DeleteMessage",
]
Resource: "arn:aws:sqs:\(_naming.region):*:\(_naming.prefix)-dlq"
},
{
Sid: "SNSPublish"
Effect: "Allow"
Action: ["sns:Publish"]
Resource: "arn:aws:sns:\(_naming.region):*:\(_naming.prefix)-alerts"
},
{
Sid: "CloudWatchLogs"
Effect: "Allow"
Action: [
"logs:CreateLogStream",
"logs:PutLogEvents",
]
Resource: "arn:aws:logs:\(_naming.region):*:log-group:/praxis/\(_naming.prefix)/app:*"
},
]
})
tags: #AppTags
}
}
}Excerpted from examples/stacks/end-to-end.cue. Open the complete example for its variables and related resources.
Desired state
Configuration
The spec block accepts 4 fields. 2 are required by the schema; fields with defaults can be omitted.
pathOptionalPath.
string | *"/""/"policyDocumentRequiredPolicy Document.
stringdescriptionOptionalDescription.
stringtagsRequiredTags.
[string]: stringObserved values
Outputs
Praxis records these values after observation. A dependent resource can read one with ${resources.<name>.outputs.<field>}.
arnStringpolicyIdStringpolicyNameStringRead without ownership
Data-source lookup
A data block reads an existing IAMPolicy and exposes its outputs without storing lifecycle state. The generic filter surface accepts id, name, and tag; supported combinations depend on the AWS identity used by this resource.
data: existing: {
kind: "IAMPolicy"
filter: {
name: "replace-with-provider-name"
}
}Adopt existing infrastructure
Import
Import persists Praxis state for an existing AWS resource. For this kind, supply: Provider identifier for the existing IAMPolicy. The example starts in observed mode so Praxis reports drift without correcting it.
praxis import IAMPolicy \
--id <provider-identifier> \
--account production \
--observeCanonical contract
Complete CUE schema
The field guide above is derived from this definition. The schema remains the source of truth for accepted values, defaults, validation constraints, and outputs in the current alpha revision.
Show the complete schema
package iam
#IAMPolicy: {
apiVersion: "praxis.io/alpha"
kind: "IAMPolicy"
metadata: {
name: string & =~"^[a-zA-Z0-9+=,.@_-]{1,128}$"
labels: [string]: string
}
spec: {
path: string | *"/"
policyDocument: string
description?: string
tags: [string]: string
}
outputs?: {
arn: string
policyId: string
policyName: string
}
}