AWS Classic
GroupPolicy
Provides an IAM policy attached to a group.
Example Usage
using System.Collections.Generic;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var myDevelopers = new Aws.Iam.Group("myDevelopers", new Aws.Iam.GroupArgs
{
Path = "/users/",
});
var myDeveloperPolicy = new Aws.Iam.GroupPolicy("myDeveloperPolicy", new Aws.Iam.GroupPolicyArgs
{
Group = myDevelopers.Name,
Policy = JsonSerializer.Serialize(new Dictionary<string, object?>
{
{ "Version", "2012-10-17" },
{ "Statement", new[]
{
new Dictionary<string, object?>
{
{ "Action", new[]
{
"ec2:Describe*",
}
},
{ "Effect", "Allow" },
{ "Resource", "*" },
},
}
},
}),
});
}
}
package main
import (
"encoding/json"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/iam"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
myDevelopers, err := iam.NewGroup(ctx, "myDevelopers", &iam.GroupArgs{
Path: pulumi.String("/users/"),
})
if err != nil {
return err
}
tmpJSON0, err := json.Marshal(map[string]interface{}{
"Version": "2012-10-17",
"Statement": []map[string]interface{}{
map[string]interface{}{
"Action": []string{
"ec2:Describe*",
},
"Effect": "Allow",
"Resource": "*",
},
},
})
if err != nil {
return err
}
json0 := string(tmpJSON0)
_, err = iam.NewGroupPolicy(ctx, "myDeveloperPolicy", &iam.GroupPolicyArgs{
Group: myDevelopers.Name,
Policy: pulumi.String(json0),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;
import static com.pulumi.codegen.internal.Serialization.*;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var myDevelopers = new Group("myDevelopers", GroupArgs.builder()
.path("/users/")
.build());
var myDeveloperPolicy = new GroupPolicy("myDeveloperPolicy", GroupPolicyArgs.builder()
.group(myDevelopers.name())
.policy(serializeJson(
jsonObject(
jsonProperty("Version", "2012-10-17"),
jsonProperty("Statement", jsonArray(jsonObject(
jsonProperty("Action", jsonArray("ec2:Describe*")),
jsonProperty("Effect", "Allow"),
jsonProperty("Resource", "*")
)))
)))
.build());
}
}
import pulumi
import json
import pulumi_aws as aws
my_developers = aws.iam.Group("myDevelopers", path="/users/")
my_developer_policy = aws.iam.GroupPolicy("myDeveloperPolicy",
group=my_developers.name,
policy=json.dumps({
"Version": "2012-10-17",
"Statement": [{
"Action": ["ec2:Describe*"],
"Effect": "Allow",
"Resource": "*",
}],
}))
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const myDevelopers = new aws.iam.Group("myDevelopers", {path: "/users/"});
const myDeveloperPolicy = new aws.iam.GroupPolicy("myDeveloperPolicy", {
group: myDevelopers.name,
policy: JSON.stringify({
Version: "2012-10-17",
Statement: [{
Action: ["ec2:Describe*"],
Effect: "Allow",
Resource: "*",
}],
}),
});
resources:
myDeveloperPolicy:
type: aws:iam:GroupPolicy
properties:
group: ${myDevelopers.name}
policy:
Fn::ToJSON:
Version: 2012-10-17
Statement:
- Action:
- ec2:Describe*
Effect: Allow
Resource: '*'
myDevelopers:
type: aws:iam:Group
properties:
path: /users/
Create a GroupPolicy Resource
new GroupPolicy(name: string, args: GroupPolicyArgs, opts?: CustomResourceOptions);
@overload
def GroupPolicy(resource_name: str,
opts: Optional[ResourceOptions] = None,
group: Optional[str] = None,
name: Optional[str] = None,
name_prefix: Optional[str] = None,
policy: Optional[str] = None)
@overload
def GroupPolicy(resource_name: str,
args: GroupPolicyArgs,
opts: Optional[ResourceOptions] = None)
func NewGroupPolicy(ctx *Context, name string, args GroupPolicyArgs, opts ...ResourceOption) (*GroupPolicy, error)
public GroupPolicy(string name, GroupPolicyArgs args, CustomResourceOptions? opts = null)
public GroupPolicy(String name, GroupPolicyArgs args)
public GroupPolicy(String name, GroupPolicyArgs args, CustomResourceOptions options)
type: aws:iam:GroupPolicy
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args GroupPolicyArgs
- 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 GroupPolicyArgs
- 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 GroupPolicyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args GroupPolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args GroupPolicyArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
GroupPolicy 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 GroupPolicy resource accepts the following input properties:
- Group string
The IAM group to attach to the policy.
- Policy string | string
The policy document. This is a JSON formatted string.
- Name string
The name of the policy. If omitted, this provider will assign a random, unique name.
- Name
Prefix string Creates a unique name beginning with the specified prefix. Conflicts with
name
.
- Group string
The IAM group to attach to the policy.
- Policy string | string
The policy document. This is a JSON formatted string.
- Name string
The name of the policy. If omitted, this provider will assign a random, unique name.
- Name
Prefix string Creates a unique name beginning with the specified prefix. Conflicts with
name
.
- group String
The IAM group to attach to the policy.
- policy String | String
The policy document. This is a JSON formatted string.
- name String
The name of the policy. If omitted, this provider will assign a random, unique name.
- name
Prefix String Creates a unique name beginning with the specified prefix. Conflicts with
name
.
- group string
The IAM group to attach to the policy.
- policy
string | Policy
Document The policy document. This is a JSON formatted string.
- name string
The name of the policy. If omitted, this provider will assign a random, unique name.
- name
Prefix string Creates a unique name beginning with the specified prefix. Conflicts with
name
.
- group str
The IAM group to attach to the policy.
- policy str | str
The policy document. This is a JSON formatted string.
- name str
The name of the policy. If omitted, this provider will assign a random, unique name.
- name_
prefix str Creates a unique name beginning with the specified prefix. Conflicts with
name
.
- group String
The IAM group to attach to the policy.
- policy String |
The policy document. This is a JSON formatted string.
- name String
The name of the policy. If omitted, this provider will assign a random, unique name.
- name
Prefix String Creates a unique name beginning with the specified prefix. Conflicts with
name
.
Outputs
All input properties are implicitly available as output properties. Additionally, the GroupPolicy resource produces the following output properties:
- Id string
The provider-assigned unique ID for this managed resource.
- Id string
The provider-assigned unique ID for this managed resource.
- id String
The provider-assigned unique ID for this managed resource.
- id string
The provider-assigned unique ID for this managed resource.
- id str
The provider-assigned unique ID for this managed resource.
- id String
The provider-assigned unique ID for this managed resource.
Look up an Existing GroupPolicy Resource
Get an existing GroupPolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: GroupPolicyState, opts?: CustomResourceOptions): GroupPolicy
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
group: Optional[str] = None,
name: Optional[str] = None,
name_prefix: Optional[str] = None,
policy: Optional[str] = None) -> GroupPolicy
func GetGroupPolicy(ctx *Context, name string, id IDInput, state *GroupPolicyState, opts ...ResourceOption) (*GroupPolicy, error)
public static GroupPolicy Get(string name, Input<string> id, GroupPolicyState? state, CustomResourceOptions? opts = null)
public static GroupPolicy get(String name, Output<String> id, GroupPolicyState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Group string
The IAM group to attach to the policy.
- Name string
The name of the policy. If omitted, this provider will assign a random, unique name.
- Name
Prefix string Creates a unique name beginning with the specified prefix. Conflicts with
name
.- Policy string | string
The policy document. This is a JSON formatted string.
- Group string
The IAM group to attach to the policy.
- Name string
The name of the policy. If omitted, this provider will assign a random, unique name.
- Name
Prefix string Creates a unique name beginning with the specified prefix. Conflicts with
name
.- Policy string | string
The policy document. This is a JSON formatted string.
- group String
The IAM group to attach to the policy.
- name String
The name of the policy. If omitted, this provider will assign a random, unique name.
- name
Prefix String Creates a unique name beginning with the specified prefix. Conflicts with
name
.- policy String | String
The policy document. This is a JSON formatted string.
- group string
The IAM group to attach to the policy.
- name string
The name of the policy. If omitted, this provider will assign a random, unique name.
- name
Prefix string Creates a unique name beginning with the specified prefix. Conflicts with
name
.- policy
string | Policy
Document The policy document. This is a JSON formatted string.
- group str
The IAM group to attach to the policy.
- name str
The name of the policy. If omitted, this provider will assign a random, unique name.
- name_
prefix str Creates a unique name beginning with the specified prefix. Conflicts with
name
.- policy str | str
The policy document. This is a JSON formatted string.
- group String
The IAM group to attach to the policy.
- name String
The name of the policy. If omitted, this provider will assign a random, unique name.
- name
Prefix String Creates a unique name beginning with the specified prefix. Conflicts with
name
.- policy String |
The policy document. This is a JSON formatted string.
Import
IAM Group Policies can be imported using the group_name:group_policy_name
, e.g.,
$ pulumi import aws:iam/groupPolicy:GroupPolicy mypolicy group_of_mypolicy_name:mypolicy_name
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
aws
Terraform Provider.