aws-iam.Policy
Explore with Pulumi AI
This resource helps you create an IAM policy.
Example Usage
using Pulumi;
using Pulumi.AwsIam;
using Pulumi.AwsIam.Inputs;
class MyStack : Stack
{
public MyStack()
{
var policy = new Policy("policy", new PolicyArgs
{
Name = "example",
Path = "/",
Description = "My example policy",
PolicyDocument =
@"{
""Version"": ""2012-10-17"",
""Statement"": [
{
""Action"": [
""ec2:Describe*""
],
""Effect"": ""Allow"",
""Resource"": ""*""
}
]
}"
});
}
[Output]
public Output<Policy> Policy { get; set; }
}
package main
import (
"encoding/json"
iam "github.com/pulumi/pulumi-aws-iam/sdk/go/aws-iam"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
policyJSON, err := json.Marshal(map[string]interface{}{
"Version": "2012-10-17",
"Statement": []interface{}{
map[string]interface{}{
"Effect": "Allow",
"Action": []string{"ec2:Describe"},
"Resource": []string{"*"},
},
},
})
if err != nil {
return err
}
policy, err := iam.NewPolicy(ctx, "policy", &iam.PolicyArgs{
Name: pulumi.String("example"),
Path: pulumi.String("/"),
Description: pulumi.String("My example policy"),
PolicyDocument: pulumi.String(string(policyJSON)),
})
if err != nil {
return err
}
ctx.Export("policy", policy)
return nil
})
}
Coming soon!
import json
import pulumi
import pulumi_aws_iam as iam
policy = iam.Policy(
'policy',
name='example',
path='/',
description='My example policy',
policy_document=json.dumps({
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ec2:Describe*"
],
"Effect": "Allow",
"Resource": "*"
}
]
})
)
import * as iam from "@pulumi/aws-iam";
export const policy = new iam.Policy("aws-iam-example-policy", {
name: "aws-iam-example-policy",
path: "/",
description: "My example policy",
policyDocument: `{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ec2:Describe*"
],
"Effect": "Allow",
"Resource": "*"
}
]
}`,
});
name: awsiam-yaml
runtime: yaml
resources:
policy:
type: "aws-iam:index:Policy"
properties:
name: "example"
path: "/"
description: "My example policy"
policyDocument: |
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ec2:Describe*"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
outputs:
policy: ${policy}
Create Policy Resource
new Policy(name: string, args: PolicyArgs, opts?: CustomResourceOptions);
@overload
def Policy(resource_name: str,
opts: Optional[ResourceOptions] = None,
description: Optional[str] = None,
name: Optional[str] = None,
path: Optional[str] = None,
policy_document: Optional[str] = None,
tags: Optional[Mapping[str, str]] = None)
@overload
def Policy(resource_name: str,
args: PolicyArgs,
opts: Optional[ResourceOptions] = None)
func NewPolicy(ctx *Context, name string, args PolicyArgs, opts ...ResourceOption) (*Policy, error)
public Policy(string name, PolicyArgs args, CustomResourceOptions? opts = null)
public Policy(String name, PolicyArgs args)
public Policy(String name, PolicyArgs args, CustomResourceOptions options)
type: aws-iam:Policy
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args PolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args PolicyArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args PolicyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args PolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args PolicyArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Policy Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The Policy resource accepts the following input properties:
- Name string
The name of the policy.
- Policy
Document string The policy document.
- Description string
The description of the policy.
- Path string
The path of the policy in IAM.
- Dictionary<string, string>
A map of tags to add.
- Name string
The name of the policy.
- Policy
Document string The policy document.
- Description string
The description of the policy.
- Path string
The path of the policy in IAM.
- map[string]string
A map of tags to add.
- name String
The name of the policy.
- policy
Document String The policy document.
- description String
The description of the policy.
- path String
The path of the policy in IAM.
- Map<String,String>
A map of tags to add.
- name string
The name of the policy.
- policy
Document string The policy document.
- description string
The description of the policy.
- path string
The path of the policy in IAM.
- {[key: string]: string}
A map of tags to add.
- name str
The name of the policy.
- policy_
document str The policy document.
- description str
The description of the policy.
- path str
The path of the policy in IAM.
- Mapping[str, str]
A map of tags to add.
- name String
The name of the policy.
- policy
Document String The policy document.
- description String
The description of the policy.
- path String
The path of the policy in IAM.
- Map<String>
A map of tags to add.
Outputs
All input properties are implicitly available as output properties. Additionally, the Policy resource produces the following output properties:
Package Details
- Repository
- aws-iam
- License