1. Packages
  2. AWS
  3. API Docs
  4. eks
  5. AccessPolicyAssociation
AWS v6.77.1 published on Friday, Apr 18, 2025 by Pulumi

aws.eks.AccessPolicyAssociation

Explore with Pulumi AI

Access Entry Policy Association for an EKS Cluster.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.eks.AccessPolicyAssociation("example", {
    clusterName: exampleAwsEksCluster.name,
    policyArn: "arn:aws:eks::aws:cluster-access-policy/AmazonEKSViewPolicy",
    principalArn: exampleAwsIamUser.arn,
    accessScope: {
        type: "namespace",
        namespaces: ["example-namespace"],
    },
});
Copy
import pulumi
import pulumi_aws as aws

example = aws.eks.AccessPolicyAssociation("example",
    cluster_name=example_aws_eks_cluster["name"],
    policy_arn="arn:aws:eks::aws:cluster-access-policy/AmazonEKSViewPolicy",
    principal_arn=example_aws_iam_user["arn"],
    access_scope={
        "type": "namespace",
        "namespaces": ["example-namespace"],
    })
Copy
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/eks"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := eks.NewAccessPolicyAssociation(ctx, "example", &eks.AccessPolicyAssociationArgs{
			ClusterName:  pulumi.Any(exampleAwsEksCluster.Name),
			PolicyArn:    pulumi.String("arn:aws:eks::aws:cluster-access-policy/AmazonEKSViewPolicy"),
			PrincipalArn: pulumi.Any(exampleAwsIamUser.Arn),
			AccessScope: &eks.AccessPolicyAssociationAccessScopeArgs{
				Type: pulumi.String("namespace"),
				Namespaces: pulumi.StringArray{
					pulumi.String("example-namespace"),
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var example = new Aws.Eks.AccessPolicyAssociation("example", new()
    {
        ClusterName = exampleAwsEksCluster.Name,
        PolicyArn = "arn:aws:eks::aws:cluster-access-policy/AmazonEKSViewPolicy",
        PrincipalArn = exampleAwsIamUser.Arn,
        AccessScope = new Aws.Eks.Inputs.AccessPolicyAssociationAccessScopeArgs
        {
            Type = "namespace",
            Namespaces = new[]
            {
                "example-namespace",
            },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.eks.AccessPolicyAssociation;
import com.pulumi.aws.eks.AccessPolicyAssociationArgs;
import com.pulumi.aws.eks.inputs.AccessPolicyAssociationAccessScopeArgs;
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 example = new AccessPolicyAssociation("example", AccessPolicyAssociationArgs.builder()
            .clusterName(exampleAwsEksCluster.name())
            .policyArn("arn:aws:eks::aws:cluster-access-policy/AmazonEKSViewPolicy")
            .principalArn(exampleAwsIamUser.arn())
            .accessScope(AccessPolicyAssociationAccessScopeArgs.builder()
                .type("namespace")
                .namespaces("example-namespace")
                .build())
            .build());

    }
}
Copy
resources:
  example:
    type: aws:eks:AccessPolicyAssociation
    properties:
      clusterName: ${exampleAwsEksCluster.name}
      policyArn: arn:aws:eks::aws:cluster-access-policy/AmazonEKSViewPolicy
      principalArn: ${exampleAwsIamUser.arn}
      accessScope:
        type: namespace
        namespaces:
          - example-namespace
Copy

Create AccessPolicyAssociation Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new AccessPolicyAssociation(name: string, args: AccessPolicyAssociationArgs, opts?: CustomResourceOptions);
@overload
def AccessPolicyAssociation(resource_name: str,
                            args: AccessPolicyAssociationArgs,
                            opts: Optional[ResourceOptions] = None)

@overload
def AccessPolicyAssociation(resource_name: str,
                            opts: Optional[ResourceOptions] = None,
                            access_scope: Optional[AccessPolicyAssociationAccessScopeArgs] = None,
                            cluster_name: Optional[str] = None,
                            policy_arn: Optional[str] = None,
                            principal_arn: Optional[str] = None)
func NewAccessPolicyAssociation(ctx *Context, name string, args AccessPolicyAssociationArgs, opts ...ResourceOption) (*AccessPolicyAssociation, error)
public AccessPolicyAssociation(string name, AccessPolicyAssociationArgs args, CustomResourceOptions? opts = null)
public AccessPolicyAssociation(String name, AccessPolicyAssociationArgs args)
public AccessPolicyAssociation(String name, AccessPolicyAssociationArgs args, CustomResourceOptions options)
type: aws:eks:AccessPolicyAssociation
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. AccessPolicyAssociationArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. AccessPolicyAssociationArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. AccessPolicyAssociationArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. AccessPolicyAssociationArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. AccessPolicyAssociationArgs
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 accessPolicyAssociationResource = new Aws.Eks.AccessPolicyAssociation("accessPolicyAssociationResource", new()
{
    AccessScope = new Aws.Eks.Inputs.AccessPolicyAssociationAccessScopeArgs
    {
        Type = "string",
        Namespaces = new[]
        {
            "string",
        },
    },
    ClusterName = "string",
    PolicyArn = "string",
    PrincipalArn = "string",
});
Copy
example, err := eks.NewAccessPolicyAssociation(ctx, "accessPolicyAssociationResource", &eks.AccessPolicyAssociationArgs{
	AccessScope: &eks.AccessPolicyAssociationAccessScopeArgs{
		Type: pulumi.String("string"),
		Namespaces: pulumi.StringArray{
			pulumi.String("string"),
		},
	},
	ClusterName:  pulumi.String("string"),
	PolicyArn:    pulumi.String("string"),
	PrincipalArn: pulumi.String("string"),
})
Copy
var accessPolicyAssociationResource = new AccessPolicyAssociation("accessPolicyAssociationResource", AccessPolicyAssociationArgs.builder()
    .accessScope(AccessPolicyAssociationAccessScopeArgs.builder()
        .type("string")
        .namespaces("string")
        .build())
    .clusterName("string")
    .policyArn("string")
    .principalArn("string")
    .build());
Copy
access_policy_association_resource = aws.eks.AccessPolicyAssociation("accessPolicyAssociationResource",
    access_scope={
        "type": "string",
        "namespaces": ["string"],
    },
    cluster_name="string",
    policy_arn="string",
    principal_arn="string")
Copy
const accessPolicyAssociationResource = new aws.eks.AccessPolicyAssociation("accessPolicyAssociationResource", {
    accessScope: {
        type: "string",
        namespaces: ["string"],
    },
    clusterName: "string",
    policyArn: "string",
    principalArn: "string",
});
Copy
type: aws:eks:AccessPolicyAssociation
properties:
    accessScope:
        namespaces:
            - string
        type: string
    clusterName: string
    policyArn: string
    principalArn: string
Copy

AccessPolicyAssociation Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The AccessPolicyAssociation resource accepts the following input properties:

AccessScope
This property is required.
Changes to this property will trigger replacement.
AccessPolicyAssociationAccessScope
The configuration block to determine the scope of the access. See access_scope Block below.
ClusterName
This property is required.
Changes to this property will trigger replacement.
string
Name of the EKS Cluster.
PolicyArn
This property is required.
Changes to this property will trigger replacement.
string
The ARN of the access policy that you're associating.
PrincipalArn
This property is required.
Changes to this property will trigger replacement.
string
The IAM Principal ARN which requires Authentication access to the EKS cluster.
AccessScope
This property is required.
Changes to this property will trigger replacement.
AccessPolicyAssociationAccessScopeArgs
The configuration block to determine the scope of the access. See access_scope Block below.
ClusterName
This property is required.
Changes to this property will trigger replacement.
string
Name of the EKS Cluster.
PolicyArn
This property is required.
Changes to this property will trigger replacement.
string
The ARN of the access policy that you're associating.
PrincipalArn
This property is required.
Changes to this property will trigger replacement.
string
The IAM Principal ARN which requires Authentication access to the EKS cluster.
accessScope
This property is required.
Changes to this property will trigger replacement.
AccessPolicyAssociationAccessScope
The configuration block to determine the scope of the access. See access_scope Block below.
clusterName
This property is required.
Changes to this property will trigger replacement.
String
Name of the EKS Cluster.
policyArn
This property is required.
Changes to this property will trigger replacement.
String
The ARN of the access policy that you're associating.
principalArn
This property is required.
Changes to this property will trigger replacement.
String
The IAM Principal ARN which requires Authentication access to the EKS cluster.
accessScope
This property is required.
Changes to this property will trigger replacement.
AccessPolicyAssociationAccessScope
The configuration block to determine the scope of the access. See access_scope Block below.
clusterName
This property is required.
Changes to this property will trigger replacement.
string
Name of the EKS Cluster.
policyArn
This property is required.
Changes to this property will trigger replacement.
string
The ARN of the access policy that you're associating.
principalArn
This property is required.
Changes to this property will trigger replacement.
string
The IAM Principal ARN which requires Authentication access to the EKS cluster.
access_scope
This property is required.
Changes to this property will trigger replacement.
AccessPolicyAssociationAccessScopeArgs
The configuration block to determine the scope of the access. See access_scope Block below.
cluster_name
This property is required.
Changes to this property will trigger replacement.
str
Name of the EKS Cluster.
policy_arn
This property is required.
Changes to this property will trigger replacement.
str
The ARN of the access policy that you're associating.
principal_arn
This property is required.
Changes to this property will trigger replacement.
str
The IAM Principal ARN which requires Authentication access to the EKS cluster.
accessScope
This property is required.
Changes to this property will trigger replacement.
Property Map
The configuration block to determine the scope of the access. See access_scope Block below.
clusterName
This property is required.
Changes to this property will trigger replacement.
String
Name of the EKS Cluster.
policyArn
This property is required.
Changes to this property will trigger replacement.
String
The ARN of the access policy that you're associating.
principalArn
This property is required.
Changes to this property will trigger replacement.
String
The IAM Principal ARN which requires Authentication access to the EKS cluster.

Outputs

All input properties are implicitly available as output properties. Additionally, the AccessPolicyAssociation resource produces the following output properties:

AssociatedAt string
Date and time in RFC3339 format that the policy was associated.
Id string
The provider-assigned unique ID for this managed resource.
ModifiedAt string
Date and time in RFC3339 format that the policy was updated.
AssociatedAt string
Date and time in RFC3339 format that the policy was associated.
Id string
The provider-assigned unique ID for this managed resource.
ModifiedAt string
Date and time in RFC3339 format that the policy was updated.
associatedAt String
Date and time in RFC3339 format that the policy was associated.
id String
The provider-assigned unique ID for this managed resource.
modifiedAt String
Date and time in RFC3339 format that the policy was updated.
associatedAt string
Date and time in RFC3339 format that the policy was associated.
id string
The provider-assigned unique ID for this managed resource.
modifiedAt string
Date and time in RFC3339 format that the policy was updated.
associated_at str
Date and time in RFC3339 format that the policy was associated.
id str
The provider-assigned unique ID for this managed resource.
modified_at str
Date and time in RFC3339 format that the policy was updated.
associatedAt String
Date and time in RFC3339 format that the policy was associated.
id String
The provider-assigned unique ID for this managed resource.
modifiedAt String
Date and time in RFC3339 format that the policy was updated.

Look up Existing AccessPolicyAssociation Resource

Get an existing AccessPolicyAssociation 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?: AccessPolicyAssociationState, opts?: CustomResourceOptions): AccessPolicyAssociation
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        access_scope: Optional[AccessPolicyAssociationAccessScopeArgs] = None,
        associated_at: Optional[str] = None,
        cluster_name: Optional[str] = None,
        modified_at: Optional[str] = None,
        policy_arn: Optional[str] = None,
        principal_arn: Optional[str] = None) -> AccessPolicyAssociation
func GetAccessPolicyAssociation(ctx *Context, name string, id IDInput, state *AccessPolicyAssociationState, opts ...ResourceOption) (*AccessPolicyAssociation, error)
public static AccessPolicyAssociation Get(string name, Input<string> id, AccessPolicyAssociationState? state, CustomResourceOptions? opts = null)
public static AccessPolicyAssociation get(String name, Output<String> id, AccessPolicyAssociationState state, CustomResourceOptions options)
resources:  _:    type: aws:eks:AccessPolicyAssociation    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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.
The following state arguments are supported:
AccessScope Changes to this property will trigger replacement. AccessPolicyAssociationAccessScope
The configuration block to determine the scope of the access. See access_scope Block below.
AssociatedAt string
Date and time in RFC3339 format that the policy was associated.
ClusterName Changes to this property will trigger replacement. string
Name of the EKS Cluster.
ModifiedAt string
Date and time in RFC3339 format that the policy was updated.
PolicyArn Changes to this property will trigger replacement. string
The ARN of the access policy that you're associating.
PrincipalArn Changes to this property will trigger replacement. string
The IAM Principal ARN which requires Authentication access to the EKS cluster.
AccessScope Changes to this property will trigger replacement. AccessPolicyAssociationAccessScopeArgs
The configuration block to determine the scope of the access. See access_scope Block below.
AssociatedAt string
Date and time in RFC3339 format that the policy was associated.
ClusterName Changes to this property will trigger replacement. string
Name of the EKS Cluster.
ModifiedAt string
Date and time in RFC3339 format that the policy was updated.
PolicyArn Changes to this property will trigger replacement. string
The ARN of the access policy that you're associating.
PrincipalArn Changes to this property will trigger replacement. string
The IAM Principal ARN which requires Authentication access to the EKS cluster.
accessScope Changes to this property will trigger replacement. AccessPolicyAssociationAccessScope
The configuration block to determine the scope of the access. See access_scope Block below.
associatedAt String
Date and time in RFC3339 format that the policy was associated.
clusterName Changes to this property will trigger replacement. String
Name of the EKS Cluster.
modifiedAt String
Date and time in RFC3339 format that the policy was updated.
policyArn Changes to this property will trigger replacement. String
The ARN of the access policy that you're associating.
principalArn Changes to this property will trigger replacement. String
The IAM Principal ARN which requires Authentication access to the EKS cluster.
accessScope Changes to this property will trigger replacement. AccessPolicyAssociationAccessScope
The configuration block to determine the scope of the access. See access_scope Block below.
associatedAt string
Date and time in RFC3339 format that the policy was associated.
clusterName Changes to this property will trigger replacement. string
Name of the EKS Cluster.
modifiedAt string
Date and time in RFC3339 format that the policy was updated.
policyArn Changes to this property will trigger replacement. string
The ARN of the access policy that you're associating.
principalArn Changes to this property will trigger replacement. string
The IAM Principal ARN which requires Authentication access to the EKS cluster.
access_scope Changes to this property will trigger replacement. AccessPolicyAssociationAccessScopeArgs
The configuration block to determine the scope of the access. See access_scope Block below.
associated_at str
Date and time in RFC3339 format that the policy was associated.
cluster_name Changes to this property will trigger replacement. str
Name of the EKS Cluster.
modified_at str
Date and time in RFC3339 format that the policy was updated.
policy_arn Changes to this property will trigger replacement. str
The ARN of the access policy that you're associating.
principal_arn Changes to this property will trigger replacement. str
The IAM Principal ARN which requires Authentication access to the EKS cluster.
accessScope Changes to this property will trigger replacement. Property Map
The configuration block to determine the scope of the access. See access_scope Block below.
associatedAt String
Date and time in RFC3339 format that the policy was associated.
clusterName Changes to this property will trigger replacement. String
Name of the EKS Cluster.
modifiedAt String
Date and time in RFC3339 format that the policy was updated.
policyArn Changes to this property will trigger replacement. String
The ARN of the access policy that you're associating.
principalArn Changes to this property will trigger replacement. String
The IAM Principal ARN which requires Authentication access to the EKS cluster.

Supporting Types

AccessPolicyAssociationAccessScope
, AccessPolicyAssociationAccessScopeArgs

Type
This property is required.
Changes to this property will trigger replacement.
string
Valid values are namespace or cluster.
Namespaces Changes to this property will trigger replacement. List<string>
The namespaces to which the access scope applies when type is namespace.
Type
This property is required.
Changes to this property will trigger replacement.
string
Valid values are namespace or cluster.
Namespaces Changes to this property will trigger replacement. []string
The namespaces to which the access scope applies when type is namespace.
type
This property is required.
Changes to this property will trigger replacement.
String
Valid values are namespace or cluster.
namespaces Changes to this property will trigger replacement. List<String>
The namespaces to which the access scope applies when type is namespace.
type
This property is required.
Changes to this property will trigger replacement.
string
Valid values are namespace or cluster.
namespaces Changes to this property will trigger replacement. string[]
The namespaces to which the access scope applies when type is namespace.
type
This property is required.
Changes to this property will trigger replacement.
str
Valid values are namespace or cluster.
namespaces Changes to this property will trigger replacement. Sequence[str]
The namespaces to which the access scope applies when type is namespace.
type
This property is required.
Changes to this property will trigger replacement.
String
Valid values are namespace or cluster.
namespaces Changes to this property will trigger replacement. List<String>
The namespaces to which the access scope applies when type is namespace.

Import

Using pulumi import, import EKS access entry using the cluster_name principal_arn and policy_arn separated by an octothorp (#). For example:

$ pulumi import aws:eks/accessPolicyAssociation:AccessPolicyAssociation my_eks_access_entry my_cluster_name#my_principal_arn#my_policy_arn
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.