1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. accesscontextmanager
  5. ServicePerimeterDryRunResource
Google Cloud v8.25.1 published on Wednesday, Apr 9, 2025 by Pulumi

gcp.accesscontextmanager.ServicePerimeterDryRunResource

Explore with Pulumi AI

Allows configuring a single GCP resource that should be inside of the spec block of a dry run service perimeter. This resource is intended to be used in cases where it is not possible to compile a full list of projects to include in a gcp.accesscontextmanager.ServicePerimeter resource, to enable them to be added separately. If your perimeter is NOT in dry-run mode use gcp.accesscontextmanager.ServicePerimeterResource instead.

Note: If this resource is used alongside a gcp.accesscontextmanager.ServicePerimeter resource, the service perimeter resource must have a lifecycle block with ignore_changes = [spec[0].resources] so they don’t fight over which resources should be in the policy.

To get more information about ServicePerimeterDryRunResource, see:

Warning: If you are using User ADCs (Application Default Credentials) with this resource, you must specify a billing_project and set user_project_override to true in the provider configuration. Otherwise the ACM API will return a 403 error. Your account must have the serviceusage.services.use permission on the billing_project you defined.

Example Usage

Access Context Manager Service Perimeter Dry Run Resource Basic

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

const access_policy = new gcp.accesscontextmanager.AccessPolicy("access-policy", {
    parent: "organizations/123456789",
    title: "my policy",
});
const service_perimeter_dry_run_resourceServicePerimeter = new gcp.accesscontextmanager.ServicePerimeter("service-perimeter-dry-run-resource", {
    parent: pulumi.interpolate`accessPolicies/${access_policy.name}`,
    name: pulumi.interpolate`accessPolicies/${access_policy.name}/servicePerimeters/restrict_all`,
    title: "restrict_all",
    spec: {
        restrictedServices: ["storage.googleapis.com"],
    },
    useExplicitDryRunSpec: true,
});
const service_perimeter_dry_run_resource = new gcp.accesscontextmanager.ServicePerimeterDryRunResource("service-perimeter-dry-run-resource", {
    perimeterName: service_perimeter_dry_run_resourceServicePerimeter.name,
    resource: "projects/987654321",
});
Copy
import pulumi
import pulumi_gcp as gcp

access_policy = gcp.accesscontextmanager.AccessPolicy("access-policy",
    parent="organizations/123456789",
    title="my policy")
service_perimeter_dry_run_resource_service_perimeter = gcp.accesscontextmanager.ServicePerimeter("service-perimeter-dry-run-resource",
    parent=access_policy.name.apply(lambda name: f"accessPolicies/{name}"),
    name=access_policy.name.apply(lambda name: f"accessPolicies/{name}/servicePerimeters/restrict_all"),
    title="restrict_all",
    spec={
        "restricted_services": ["storage.googleapis.com"],
    },
    use_explicit_dry_run_spec=True)
service_perimeter_dry_run_resource = gcp.accesscontextmanager.ServicePerimeterDryRunResource("service-perimeter-dry-run-resource",
    perimeter_name=service_perimeter_dry_run_resource_service_perimeter.name,
    resource="projects/987654321")
Copy
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/accesscontextmanager"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		access_policy, err := accesscontextmanager.NewAccessPolicy(ctx, "access-policy", &accesscontextmanager.AccessPolicyArgs{
			Parent: pulumi.String("organizations/123456789"),
			Title:  pulumi.String("my policy"),
		})
		if err != nil {
			return err
		}
		service_perimeter_dry_run_resourceServicePerimeter, err := accesscontextmanager.NewServicePerimeter(ctx, "service-perimeter-dry-run-resource", &accesscontextmanager.ServicePerimeterArgs{
			Parent: access_policy.Name.ApplyT(func(name string) (string, error) {
				return fmt.Sprintf("accessPolicies/%v", name), nil
			}).(pulumi.StringOutput),
			Name: access_policy.Name.ApplyT(func(name string) (string, error) {
				return fmt.Sprintf("accessPolicies/%v/servicePerimeters/restrict_all", name), nil
			}).(pulumi.StringOutput),
			Title: pulumi.String("restrict_all"),
			Spec: &accesscontextmanager.ServicePerimeterSpecArgs{
				RestrictedServices: pulumi.StringArray{
					pulumi.String("storage.googleapis.com"),
				},
			},
			UseExplicitDryRunSpec: pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		_, err = accesscontextmanager.NewServicePerimeterDryRunResource(ctx, "service-perimeter-dry-run-resource", &accesscontextmanager.ServicePerimeterDryRunResourceArgs{
			PerimeterName: service_perimeter_dry_run_resourceServicePerimeter.Name,
			Resource:      pulumi.String("projects/987654321"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var access_policy = new Gcp.AccessContextManager.AccessPolicy("access-policy", new()
    {
        Parent = "organizations/123456789",
        Title = "my policy",
    });

    var service_perimeter_dry_run_resourceServicePerimeter = new Gcp.AccessContextManager.ServicePerimeter("service-perimeter-dry-run-resource", new()
    {
        Parent = access_policy.Name.Apply(name => $"accessPolicies/{name}"),
        Name = access_policy.Name.Apply(name => $"accessPolicies/{name}/servicePerimeters/restrict_all"),
        Title = "restrict_all",
        Spec = new Gcp.AccessContextManager.Inputs.ServicePerimeterSpecArgs
        {
            RestrictedServices = new[]
            {
                "storage.googleapis.com",
            },
        },
        UseExplicitDryRunSpec = true,
    });

    var service_perimeter_dry_run_resource = new Gcp.AccessContextManager.ServicePerimeterDryRunResource("service-perimeter-dry-run-resource", new()
    {
        PerimeterName = service_perimeter_dry_run_resourceServicePerimeter.Name,
        Resource = "projects/987654321",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.accesscontextmanager.AccessPolicy;
import com.pulumi.gcp.accesscontextmanager.AccessPolicyArgs;
import com.pulumi.gcp.accesscontextmanager.ServicePerimeter;
import com.pulumi.gcp.accesscontextmanager.ServicePerimeterArgs;
import com.pulumi.gcp.accesscontextmanager.inputs.ServicePerimeterSpecArgs;
import com.pulumi.gcp.accesscontextmanager.ServicePerimeterDryRunResource;
import com.pulumi.gcp.accesscontextmanager.ServicePerimeterDryRunResourceArgs;
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 access_policy = new AccessPolicy("access-policy", AccessPolicyArgs.builder()
            .parent("organizations/123456789")
            .title("my policy")
            .build());

        var service_perimeter_dry_run_resourceServicePerimeter = new ServicePerimeter("service-perimeter-dry-run-resourceServicePerimeter", ServicePerimeterArgs.builder()
            .parent(access_policy.name().applyValue(_name -> String.format("accessPolicies/%s", _name)))
            .name(access_policy.name().applyValue(_name -> String.format("accessPolicies/%s/servicePerimeters/restrict_all", _name)))
            .title("restrict_all")
            .spec(ServicePerimeterSpecArgs.builder()
                .restrictedServices("storage.googleapis.com")
                .build())
            .useExplicitDryRunSpec(true)
            .build());

        var service_perimeter_dry_run_resource = new ServicePerimeterDryRunResource("service-perimeter-dry-run-resource", ServicePerimeterDryRunResourceArgs.builder()
            .perimeterName(service_perimeter_dry_run_resourceServicePerimeter.name())
            .resource("projects/987654321")
            .build());

    }
}
Copy
resources:
  service-perimeter-dry-run-resource:
    type: gcp:accesscontextmanager:ServicePerimeterDryRunResource
    properties:
      perimeterName: ${["service-perimeter-dry-run-resourceServicePerimeter"].name}
      resource: projects/987654321
  service-perimeter-dry-run-resourceServicePerimeter:
    type: gcp:accesscontextmanager:ServicePerimeter
    name: service-perimeter-dry-run-resource
    properties:
      parent: accessPolicies/${["access-policy"].name}
      name: accessPolicies/${["access-policy"].name}/servicePerimeters/restrict_all
      title: restrict_all
      spec:
        restrictedServices:
          - storage.googleapis.com
      useExplicitDryRunSpec: true
  access-policy:
    type: gcp:accesscontextmanager:AccessPolicy
    properties:
      parent: organizations/123456789
      title: my policy
Copy

Create ServicePerimeterDryRunResource Resource

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

Constructor syntax

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

@overload
def ServicePerimeterDryRunResource(resource_name: str,
                                   opts: Optional[ResourceOptions] = None,
                                   perimeter_name: Optional[str] = None,
                                   resource: Optional[str] = None)
func NewServicePerimeterDryRunResource(ctx *Context, name string, args ServicePerimeterDryRunResourceArgs, opts ...ResourceOption) (*ServicePerimeterDryRunResource, error)
public ServicePerimeterDryRunResource(string name, ServicePerimeterDryRunResourceArgs args, CustomResourceOptions? opts = null)
public ServicePerimeterDryRunResource(String name, ServicePerimeterDryRunResourceArgs args)
public ServicePerimeterDryRunResource(String name, ServicePerimeterDryRunResourceArgs args, CustomResourceOptions options)
type: gcp:accesscontextmanager:ServicePerimeterDryRunResource
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. ServicePerimeterDryRunResourceArgs
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. ServicePerimeterDryRunResourceArgs
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. ServicePerimeterDryRunResourceArgs
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. ServicePerimeterDryRunResourceArgs
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. ServicePerimeterDryRunResourceArgs
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 servicePerimeterDryRunResourceResource = new Gcp.AccessContextManager.ServicePerimeterDryRunResource("servicePerimeterDryRunResourceResource", new()
{
    PerimeterName = "string",
    Resource = "string",
});
Copy
example, err := accesscontextmanager.NewServicePerimeterDryRunResource(ctx, "servicePerimeterDryRunResourceResource", &accesscontextmanager.ServicePerimeterDryRunResourceArgs{
	PerimeterName: pulumi.String("string"),
	Resource:      pulumi.String("string"),
})
Copy
var servicePerimeterDryRunResourceResource = new ServicePerimeterDryRunResource("servicePerimeterDryRunResourceResource", ServicePerimeterDryRunResourceArgs.builder()
    .perimeterName("string")
    .resource("string")
    .build());
Copy
service_perimeter_dry_run_resource_resource = gcp.accesscontextmanager.ServicePerimeterDryRunResource("servicePerimeterDryRunResourceResource",
    perimeter_name="string",
    resource="string")
Copy
const servicePerimeterDryRunResourceResource = new gcp.accesscontextmanager.ServicePerimeterDryRunResource("servicePerimeterDryRunResourceResource", {
    perimeterName: "string",
    resource: "string",
});
Copy
type: gcp:accesscontextmanager:ServicePerimeterDryRunResource
properties:
    perimeterName: string
    resource: string
Copy

ServicePerimeterDryRunResource 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 ServicePerimeterDryRunResource resource accepts the following input properties:

PerimeterName
This property is required.
Changes to this property will trigger replacement.
string
The name of the Service Perimeter to add this resource to.


Resource
This property is required.
Changes to this property will trigger replacement.
string
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
PerimeterName
This property is required.
Changes to this property will trigger replacement.
string
The name of the Service Perimeter to add this resource to.


Resource
This property is required.
Changes to this property will trigger replacement.
string
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
perimeterName
This property is required.
Changes to this property will trigger replacement.
String
The name of the Service Perimeter to add this resource to.


resource
This property is required.
Changes to this property will trigger replacement.
String
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
perimeterName
This property is required.
Changes to this property will trigger replacement.
string
The name of the Service Perimeter to add this resource to.


resource
This property is required.
Changes to this property will trigger replacement.
string
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
perimeter_name
This property is required.
Changes to this property will trigger replacement.
str
The name of the Service Perimeter to add this resource to.


resource
This property is required.
Changes to this property will trigger replacement.
str
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
perimeterName
This property is required.
Changes to this property will trigger replacement.
String
The name of the Service Perimeter to add this resource to.


resource
This property is required.
Changes to this property will trigger replacement.
String
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}

Outputs

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

AccessPolicyId string
The name of the Access Policy this resource belongs to.
Etag string
The perimeter etag is internally used to prevent overwriting the list of perimeter resources on PATCH calls. It is retrieved from the same GET perimeter API call that's used to get the current list of resources. The resource to add or remove is merged into that list and then this etag is sent with the PATCH call along with the updated resource list.
Id string
The provider-assigned unique ID for this managed resource.
AccessPolicyId string
The name of the Access Policy this resource belongs to.
Etag string
The perimeter etag is internally used to prevent overwriting the list of perimeter resources on PATCH calls. It is retrieved from the same GET perimeter API call that's used to get the current list of resources. The resource to add or remove is merged into that list and then this etag is sent with the PATCH call along with the updated resource list.
Id string
The provider-assigned unique ID for this managed resource.
accessPolicyId String
The name of the Access Policy this resource belongs to.
etag String
The perimeter etag is internally used to prevent overwriting the list of perimeter resources on PATCH calls. It is retrieved from the same GET perimeter API call that's used to get the current list of resources. The resource to add or remove is merged into that list and then this etag is sent with the PATCH call along with the updated resource list.
id String
The provider-assigned unique ID for this managed resource.
accessPolicyId string
The name of the Access Policy this resource belongs to.
etag string
The perimeter etag is internally used to prevent overwriting the list of perimeter resources on PATCH calls. It is retrieved from the same GET perimeter API call that's used to get the current list of resources. The resource to add or remove is merged into that list and then this etag is sent with the PATCH call along with the updated resource list.
id string
The provider-assigned unique ID for this managed resource.
access_policy_id str
The name of the Access Policy this resource belongs to.
etag str
The perimeter etag is internally used to prevent overwriting the list of perimeter resources on PATCH calls. It is retrieved from the same GET perimeter API call that's used to get the current list of resources. The resource to add or remove is merged into that list and then this etag is sent with the PATCH call along with the updated resource list.
id str
The provider-assigned unique ID for this managed resource.
accessPolicyId String
The name of the Access Policy this resource belongs to.
etag String
The perimeter etag is internally used to prevent overwriting the list of perimeter resources on PATCH calls. It is retrieved from the same GET perimeter API call that's used to get the current list of resources. The resource to add or remove is merged into that list and then this etag is sent with the PATCH call along with the updated resource list.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing ServicePerimeterDryRunResource Resource

Get an existing ServicePerimeterDryRunResource 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?: ServicePerimeterDryRunResourceState, opts?: CustomResourceOptions): ServicePerimeterDryRunResource
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        access_policy_id: Optional[str] = None,
        etag: Optional[str] = None,
        perimeter_name: Optional[str] = None,
        resource: Optional[str] = None) -> ServicePerimeterDryRunResource
func GetServicePerimeterDryRunResource(ctx *Context, name string, id IDInput, state *ServicePerimeterDryRunResourceState, opts ...ResourceOption) (*ServicePerimeterDryRunResource, error)
public static ServicePerimeterDryRunResource Get(string name, Input<string> id, ServicePerimeterDryRunResourceState? state, CustomResourceOptions? opts = null)
public static ServicePerimeterDryRunResource get(String name, Output<String> id, ServicePerimeterDryRunResourceState state, CustomResourceOptions options)
resources:  _:    type: gcp:accesscontextmanager:ServicePerimeterDryRunResource    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:
AccessPolicyId string
The name of the Access Policy this resource belongs to.
Etag string
The perimeter etag is internally used to prevent overwriting the list of perimeter resources on PATCH calls. It is retrieved from the same GET perimeter API call that's used to get the current list of resources. The resource to add or remove is merged into that list and then this etag is sent with the PATCH call along with the updated resource list.
PerimeterName Changes to this property will trigger replacement. string
The name of the Service Perimeter to add this resource to.


Resource Changes to this property will trigger replacement. string
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
AccessPolicyId string
The name of the Access Policy this resource belongs to.
Etag string
The perimeter etag is internally used to prevent overwriting the list of perimeter resources on PATCH calls. It is retrieved from the same GET perimeter API call that's used to get the current list of resources. The resource to add or remove is merged into that list and then this etag is sent with the PATCH call along with the updated resource list.
PerimeterName Changes to this property will trigger replacement. string
The name of the Service Perimeter to add this resource to.


Resource Changes to this property will trigger replacement. string
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
accessPolicyId String
The name of the Access Policy this resource belongs to.
etag String
The perimeter etag is internally used to prevent overwriting the list of perimeter resources on PATCH calls. It is retrieved from the same GET perimeter API call that's used to get the current list of resources. The resource to add or remove is merged into that list and then this etag is sent with the PATCH call along with the updated resource list.
perimeterName Changes to this property will trigger replacement. String
The name of the Service Perimeter to add this resource to.


resource Changes to this property will trigger replacement. String
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
accessPolicyId string
The name of the Access Policy this resource belongs to.
etag string
The perimeter etag is internally used to prevent overwriting the list of perimeter resources on PATCH calls. It is retrieved from the same GET perimeter API call that's used to get the current list of resources. The resource to add or remove is merged into that list and then this etag is sent with the PATCH call along with the updated resource list.
perimeterName Changes to this property will trigger replacement. string
The name of the Service Perimeter to add this resource to.


resource Changes to this property will trigger replacement. string
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
access_policy_id str
The name of the Access Policy this resource belongs to.
etag str
The perimeter etag is internally used to prevent overwriting the list of perimeter resources on PATCH calls. It is retrieved from the same GET perimeter API call that's used to get the current list of resources. The resource to add or remove is merged into that list and then this etag is sent with the PATCH call along with the updated resource list.
perimeter_name Changes to this property will trigger replacement. str
The name of the Service Perimeter to add this resource to.


resource Changes to this property will trigger replacement. str
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
accessPolicyId String
The name of the Access Policy this resource belongs to.
etag String
The perimeter etag is internally used to prevent overwriting the list of perimeter resources on PATCH calls. It is retrieved from the same GET perimeter API call that's used to get the current list of resources. The resource to add or remove is merged into that list and then this etag is sent with the PATCH call along with the updated resource list.
perimeterName Changes to this property will trigger replacement. String
The name of the Service Perimeter to add this resource to.


resource Changes to this property will trigger replacement. String
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}

Import

ServicePerimeterDryRunResource can be imported using any of these accepted formats:

  • {{perimeter_name}}/{{resource}}

When using the pulumi import command, ServicePerimeterDryRunResource can be imported using one of the formats above. For example:

$ pulumi import gcp:accesscontextmanager/servicePerimeterDryRunResource:ServicePerimeterDryRunResource default {{perimeter_name}}/{{resource}}
Copy

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

Package Details

Repository
Google Cloud (GCP) Classic pulumi/pulumi-gcp
License
Apache-2.0
Notes
This Pulumi package is based on the google-beta Terraform Provider.