The gcp:containeranalysis/noteIamPolicy:NoteIamPolicy resource, part of the Pulumi GCP provider, manages IAM policies for Container Analysis notes, controlling who can view or modify vulnerability and compliance metadata. This guide focuses on three approaches: authoritative policy replacement (NoteIamPolicy), role-level member management (NoteIamBinding), and individual member grants (NoteIamMember).
These resources reference existing Container Analysis notes and require the Container Analysis API enabled in your project. The examples are intentionally small. Combine them with your own note definitions and organizational access patterns. Note that NoteIamPolicy cannot be used alongside NoteIamBinding or NoteIamMember, as they will conflict over policy ownership.
Replace the entire IAM policy for a note
When you need complete control over who can access a Container Analysis note, you can set the entire IAM policy at once.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const admin = gcp.organizations.getIAMPolicy({
bindings: [{
role: "roles/containeranalysis.notes.occurrences.viewer",
members: ["user:jane@example.com"],
}],
});
const policy = new gcp.containeranalysis.NoteIamPolicy("policy", {
project: note.project,
note: note.name,
policyData: admin.then(admin => admin.policyData),
});
import pulumi
import pulumi_gcp as gcp
admin = gcp.organizations.get_iam_policy(bindings=[{
"role": "roles/containeranalysis.notes.occurrences.viewer",
"members": ["user:jane@example.com"],
}])
policy = gcp.containeranalysis.NoteIamPolicy("policy",
project=note["project"],
note=note["name"],
policy_data=admin.policy_data)
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/containeranalysis"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/organizations"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
admin, err := organizations.LookupIAMPolicy(ctx, &organizations.LookupIAMPolicyArgs{
Bindings: []organizations.GetIAMPolicyBinding{
{
Role: "roles/containeranalysis.notes.occurrences.viewer",
Members: []string{
"user:jane@example.com",
},
},
},
}, nil)
if err != nil {
return err
}
_, err = containeranalysis.NewNoteIamPolicy(ctx, "policy", &containeranalysis.NoteIamPolicyArgs{
Project: pulumi.Any(note.Project),
Note: pulumi.Any(note.Name),
PolicyData: pulumi.String(admin.PolicyData),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var admin = Gcp.Organizations.GetIAMPolicy.Invoke(new()
{
Bindings = new[]
{
new Gcp.Organizations.Inputs.GetIAMPolicyBindingInputArgs
{
Role = "roles/containeranalysis.notes.occurrences.viewer",
Members = new[]
{
"user:jane@example.com",
},
},
},
});
var policy = new Gcp.ContainerAnalysis.NoteIamPolicy("policy", new()
{
Project = note.Project,
Note = note.Name,
PolicyData = admin.Apply(getIAMPolicyResult => getIAMPolicyResult.PolicyData),
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.organizations.OrganizationsFunctions;
import com.pulumi.gcp.organizations.inputs.GetIAMPolicyArgs;
import com.pulumi.gcp.containeranalysis.NoteIamPolicy;
import com.pulumi.gcp.containeranalysis.NoteIamPolicyArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var admin = OrganizationsFunctions.getIAMPolicy(GetIAMPolicyArgs.builder()
.bindings(GetIAMPolicyBindingArgs.builder()
.role("roles/containeranalysis.notes.occurrences.viewer")
.members("user:jane@example.com")
.build())
.build());
var policy = new NoteIamPolicy("policy", NoteIamPolicyArgs.builder()
.project(note.project())
.note(note.name())
.policyData(admin.policyData())
.build());
}
}
resources:
policy:
type: gcp:containeranalysis:NoteIamPolicy
properties:
project: ${note.project}
note: ${note.name}
policyData: ${admin.policyData}
variables:
admin:
fn::invoke:
function: gcp:organizations:getIAMPolicy
arguments:
bindings:
- role: roles/containeranalysis.notes.occurrences.viewer
members:
- user:jane@example.com
The NoteIamPolicy resource is authoritative: it replaces any existing IAM policy on the note. The policyData comes from the getIAMPolicy data source, which defines bindings between roles and members. This approach gives you full control but requires you to specify all desired permissions in one place.
Grant a role to multiple members at once
When multiple users or service accounts need the same level of access, you can bind them all to a single role.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const binding = new gcp.containeranalysis.NoteIamBinding("binding", {
project: note.project,
note: note.name,
role: "roles/containeranalysis.notes.occurrences.viewer",
members: ["user:jane@example.com"],
});
import pulumi
import pulumi_gcp as gcp
binding = gcp.containeranalysis.NoteIamBinding("binding",
project=note["project"],
note=note["name"],
role="roles/containeranalysis.notes.occurrences.viewer",
members=["user:jane@example.com"])
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/containeranalysis"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := containeranalysis.NewNoteIamBinding(ctx, "binding", &containeranalysis.NoteIamBindingArgs{
Project: pulumi.Any(note.Project),
Note: pulumi.Any(note.Name),
Role: pulumi.String("roles/containeranalysis.notes.occurrences.viewer"),
Members: pulumi.StringArray{
pulumi.String("user:jane@example.com"),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var binding = new Gcp.ContainerAnalysis.NoteIamBinding("binding", new()
{
Project = note.Project,
Note = note.Name,
Role = "roles/containeranalysis.notes.occurrences.viewer",
Members = new[]
{
"user:jane@example.com",
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.containeranalysis.NoteIamBinding;
import com.pulumi.gcp.containeranalysis.NoteIamBindingArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var binding = new NoteIamBinding("binding", NoteIamBindingArgs.builder()
.project(note.project())
.note(note.name())
.role("roles/containeranalysis.notes.occurrences.viewer")
.members("user:jane@example.com")
.build());
}
}
resources:
binding:
type: gcp:containeranalysis:NoteIamBinding
properties:
project: ${note.project}
note: ${note.name}
role: roles/containeranalysis.notes.occurrences.viewer
members:
- user:jane@example.com
The NoteIamBinding resource is authoritative for the specified role: it replaces all members for that role while preserving other roles on the note. The members array accepts user accounts, service accounts, groups, and domains. You can use multiple NoteIamBinding resources for different roles on the same note.
Add a single member to a role incrementally
When you need to grant access to one user without affecting other members or roles, add individual members incrementally.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const member = new gcp.containeranalysis.NoteIamMember("member", {
project: note.project,
note: note.name,
role: "roles/containeranalysis.notes.occurrences.viewer",
member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp
member = gcp.containeranalysis.NoteIamMember("member",
project=note["project"],
note=note["name"],
role="roles/containeranalysis.notes.occurrences.viewer",
member="user:jane@example.com")
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/containeranalysis"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := containeranalysis.NewNoteIamMember(ctx, "member", &containeranalysis.NoteIamMemberArgs{
Project: pulumi.Any(note.Project),
Note: pulumi.Any(note.Name),
Role: pulumi.String("roles/containeranalysis.notes.occurrences.viewer"),
Member: pulumi.String("user:jane@example.com"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var member = new Gcp.ContainerAnalysis.NoteIamMember("member", new()
{
Project = note.Project,
Note = note.Name,
Role = "roles/containeranalysis.notes.occurrences.viewer",
Member = "user:jane@example.com",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.containeranalysis.NoteIamMember;
import com.pulumi.gcp.containeranalysis.NoteIamMemberArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var member = new NoteIamMember("member", NoteIamMemberArgs.builder()
.project(note.project())
.note(note.name())
.role("roles/containeranalysis.notes.occurrences.viewer")
.member("user:jane@example.com")
.build());
}
}
resources:
member:
type: gcp:containeranalysis:NoteIamMember
properties:
project: ${note.project}
note: ${note.name}
role: roles/containeranalysis.notes.occurrences.viewer
member: user:jane@example.com
The NoteIamMember resource is non-authoritative: it adds a single member to a role without replacing existing members. This is useful when multiple teams manage access independently. You can combine NoteIamMember resources with NoteIamBinding resources as long as they don’t grant the same role.
Beyond these examples
These snippets focus on specific IAM management approaches: authoritative vs non-authoritative IAM management and role-based access control for Container Analysis notes. They’re intentionally minimal rather than full access control systems.
The examples reference pre-existing infrastructure such as Container Analysis notes (by name) and a GCP project with the Container Analysis API enabled. They focus on IAM policy configuration rather than note creation or API setup.
To keep things focused, common IAM patterns are omitted, including:
- Conditional IAM bindings (conditions)
- Custom role definitions
- Service account creation and management
- Note creation and configuration
These omissions are intentional: the goal is to illustrate how each IAM resource type is wired, not provide drop-in access control modules. See the Container Analysis NoteIamPolicy resource reference for all available configuration options.
Let's manage GCP Container Analysis Note IAM Policies
Get started with Pulumi Cloud, then follow our quick setup guide to deploy this infrastructure.
Try Pulumi Cloud for FREEFrequently Asked Questions
Resource Conflicts & Compatibility
gcp.containeranalysis.NoteIamPolicy cannot be used with gcp.containeranalysis.NoteIamBinding or gcp.containeranalysis.NoteIamMember because they will conflict over the policy configuration.NoteIamPolicy is authoritative and replaces the entire IAM policy. NoteIamBinding is authoritative for a specific role, replacing all members for that role while preserving other roles. NoteIamMember is non-authoritative and adds a single member without affecting other members or roles.Configuration & Usage
gcp.organizations.getIAMPolicy data source to generate the policy data, then pass it to the policyData property.note and project properties cannot be changed after the resource is created.