AWS IAM v0.0.3 published on Wednesday, Jun 1, 2022 by Pulumi
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
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Policy(name: string, args: PolicyArgs, opts?: CustomResourceOptions);
@overload
def Policy(resource_name: str,
args: PolicyArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Policy(resource_name: str,
opts: Optional[ResourceOptions] = None,
name: Optional[str] = None,
policy_document: Optional[str] = None,
description: Optional[str] = None,
path: Optional[str] = None,
tags: Optional[Mapping[str, str]] = 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.
Parameters
- 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.
Constructor example
The following reference example uses placeholder values for all input properties.
var policyResource = new AwsIam.Policy("policyResource", new()
{
Name = "string",
PolicyDocument = "string",
Description = "string",
Path = "string",
Tags =
{
{ "string", "string" },
},
});
example, err := awsiam.NewPolicy(ctx, "policyResource", &awsiam.PolicyArgs{
Name: pulumi.String("string"),
PolicyDocument: pulumi.String("string"),
Description: pulumi.String("string"),
Path: pulumi.String("string"),
Tags: pulumi.StringMap{
"string": pulumi.String("string"),
},
})
var policyResource = new Policy("policyResource", PolicyArgs.builder()
.name("string")
.policyDocument("string")
.description("string")
.path("string")
.tags(Map.of("string", "string"))
.build());
policy_resource = aws_iam.Policy("policyResource",
name="string",
policy_document="string",
description="string",
path="string",
tags={
"string": "string",
})
const policyResource = new aws_iam.Policy("policyResource", {
name: "string",
policyDocument: "string",
description: "string",
path: "string",
tags: {
string: "string",
},
});
type: aws-iam:Policy
properties:
description: string
name: string
path: string
policyDocument: string
tags:
string: string
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