gcp.accesscontextmanager.ServicePerimeterResource
Allows configuring a single GCP resource that should be inside of a 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.
Note: If this resource is used alongside a
gcp.accesscontextmanager.ServicePerimeter
resource, the service perimeter resource must have alifecycle
block withignore_changes = [status[0].resources]
so they don’t fight over which resources should be in the policy.
To get more information about ServicePerimeterResource, see:
- API documentation
- How-to Guides
Warning: If you are using User ADCs (Application Default Credentials) with this resource, you must specify a
billing_project
and setuser_project_override
to true in the provider configuration. Otherwise the ACM API will return a 403 error. Your account must have theserviceusage.services.use
permission on thebilling_project
you defined.
Example Usage
Access Context Manager Service Perimeter Resource Basic
using System.Collections.Generic;
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_resourceServicePerimeter = new Gcp.AccessContextManager.ServicePerimeter("service-perimeter-resourceServicePerimeter", new()
{
Parent = access_policy.Name.Apply(name => $"accessPolicies/{name}"),
Title = "restrict_all",
Status = new Gcp.AccessContextManager.Inputs.ServicePerimeterStatusArgs
{
RestrictedServices = new[]
{
"storage.googleapis.com",
},
},
});
var service_perimeter_resourceServicePerimeterResource = new Gcp.AccessContextManager.ServicePerimeterResource("service-perimeter-resourceServicePerimeterResource", new()
{
PerimeterName = service_perimeter_resourceServicePerimeter.Name,
Resource = "projects/987654321",
});
});
package main
import (
"fmt"
"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/accesscontextmanager"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := accesscontextmanager.NewAccessPolicy(ctx, "access-policy", &accesscontextmanager.AccessPolicyArgs{
Parent: pulumi.String("organizations/123456789"),
Title: pulumi.String("my policy"),
})
if err != nil {
return err
}
_, err = accesscontextmanager.NewServicePerimeter(ctx, "service-perimeter-resourceServicePerimeter", &accesscontextmanager.ServicePerimeterArgs{
Parent: access_policy.Name.ApplyT(func(name string) (string, error) {
return fmt.Sprintf("accessPolicies/%v", name), nil
}).(pulumi.StringOutput),
Title: pulumi.String("restrict_all"),
Status: &accesscontextmanager.ServicePerimeterStatusArgs{
RestrictedServices: pulumi.StringArray{
pulumi.String("storage.googleapis.com"),
},
},
})
if err != nil {
return err
}
_, err = accesscontextmanager.NewServicePerimeterResource(ctx, "service-perimeter-resourceServicePerimeterResource", &accesscontextmanager.ServicePerimeterResourceArgs{
PerimeterName: service_perimeter_resourceServicePerimeter.Name,
Resource: pulumi.String("projects/987654321"),
})
if err != nil {
return err
}
return nil
})
}
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.ServicePerimeterStatusArgs;
import com.pulumi.gcp.accesscontextmanager.ServicePerimeterResource;
import com.pulumi.gcp.accesscontextmanager.ServicePerimeterResourceArgs;
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_resourceServicePerimeter = new ServicePerimeter("service-perimeter-resourceServicePerimeter", ServicePerimeterArgs.builder()
.parent(access_policy.name().applyValue(name -> String.format("accessPolicies/%s", name)))
.title("restrict_all")
.status(ServicePerimeterStatusArgs.builder()
.restrictedServices("storage.googleapis.com")
.build())
.build());
var service_perimeter_resourceServicePerimeterResource = new ServicePerimeterResource("service-perimeter-resourceServicePerimeterResource", ServicePerimeterResourceArgs.builder()
.perimeterName(service_perimeter_resourceServicePerimeter.name())
.resource("projects/987654321")
.build());
}
}
import pulumi
import pulumi_gcp as gcp
access_policy = gcp.accesscontextmanager.AccessPolicy("access-policy",
parent="organizations/123456789",
title="my policy")
service_perimeter_resource_service_perimeter = gcp.accesscontextmanager.ServicePerimeter("service-perimeter-resourceServicePerimeter",
parent=access_policy.name.apply(lambda name: f"accessPolicies/{name}"),
title="restrict_all",
status=gcp.accesscontextmanager.ServicePerimeterStatusArgs(
restricted_services=["storage.googleapis.com"],
))
service_perimeter_resource_service_perimeter_resource = gcp.accesscontextmanager.ServicePerimeterResource("service-perimeter-resourceServicePerimeterResource",
perimeter_name=service_perimeter_resource_service_perimeter.name,
resource="projects/987654321")
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_resourceServicePerimeter = new gcp.accesscontextmanager.ServicePerimeter("service-perimeter-resourceServicePerimeter", {
parent: pulumi.interpolate`accessPolicies/${access_policy.name}`,
title: "restrict_all",
status: {
restrictedServices: ["storage.googleapis.com"],
},
});
const service_perimeter_resourceServicePerimeterResource = new gcp.accesscontextmanager.ServicePerimeterResource("service-perimeter-resourceServicePerimeterResource", {
perimeterName: service_perimeter_resourceServicePerimeter.name,
resource: "projects/987654321",
});
resources:
service-perimeter-resourceServicePerimeterResource:
type: gcp:accesscontextmanager:ServicePerimeterResource
properties:
perimeterName: ${["service-perimeter-resourceServicePerimeter"].name}
resource: projects/987654321
service-perimeter-resourceServicePerimeter:
type: gcp:accesscontextmanager:ServicePerimeter
properties:
parent: accessPolicies/${["access-policy"].name}
title: restrict_all
status:
restrictedServices:
- storage.googleapis.com
access-policy:
type: gcp:accesscontextmanager:AccessPolicy
properties:
parent: organizations/123456789
title: my policy
Create ServicePerimeterResource Resource
new ServicePerimeterResource(name: string, args: ServicePerimeterResourceArgs, opts?: CustomResourceOptions);
@overload
def ServicePerimeterResource(resource_name: str,
opts: Optional[ResourceOptions] = None,
perimeter_name: Optional[str] = None,
resource: Optional[str] = None)
@overload
def ServicePerimeterResource(resource_name: str,
args: ServicePerimeterResourceArgs,
opts: Optional[ResourceOptions] = None)
func NewServicePerimeterResource(ctx *Context, name string, args ServicePerimeterResourceArgs, opts ...ResourceOption) (*ServicePerimeterResource, error)
public ServicePerimeterResource(string name, ServicePerimeterResourceArgs args, CustomResourceOptions? opts = null)
public ServicePerimeterResource(String name, ServicePerimeterResourceArgs args)
public ServicePerimeterResource(String name, ServicePerimeterResourceArgs args, CustomResourceOptions options)
type: gcp:accesscontextmanager:ServicePerimeterResource
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ServicePerimeterResourceArgs
- 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 ServicePerimeterResourceArgs
- 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 ServicePerimeterResourceArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ServicePerimeterResourceArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ServicePerimeterResourceArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
ServicePerimeterResource 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 ServicePerimeterResource resource accepts the following input properties:
- Perimeter
Name string The name of the Service Perimeter to add this resource to.
- Resource string
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
- Perimeter
Name string The name of the Service Perimeter to add this resource to.
- Resource string
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
- perimeter
Name String The name of the Service Perimeter to add this resource to.
- resource String
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
- perimeter
Name string The name of the Service Perimeter to add this resource to.
- resource string
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
- perimeter_
name str The name of the Service Perimeter to add this resource to.
- resource str
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
- perimeter
Name String The name of the Service Perimeter to add this resource to.
- resource 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 ServicePerimeterResource 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 Existing ServicePerimeterResource Resource
Get an existing ServicePerimeterResource 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?: ServicePerimeterResourceState, opts?: CustomResourceOptions): ServicePerimeterResource
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
perimeter_name: Optional[str] = None,
resource: Optional[str] = None) -> ServicePerimeterResource
func GetServicePerimeterResource(ctx *Context, name string, id IDInput, state *ServicePerimeterResourceState, opts ...ResourceOption) (*ServicePerimeterResource, error)
public static ServicePerimeterResource Get(string name, Input<string> id, ServicePerimeterResourceState? state, CustomResourceOptions? opts = null)
public static ServicePerimeterResource get(String name, Output<String> id, ServicePerimeterResourceState 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.
- Perimeter
Name string The name of the Service Perimeter to add this resource to.
- Resource string
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
- Perimeter
Name string The name of the Service Perimeter to add this resource to.
- Resource string
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
- perimeter
Name String The name of the Service Perimeter to add this resource to.
- resource String
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
- perimeter
Name string The name of the Service Perimeter to add this resource to.
- resource string
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
- perimeter_
name str The name of the Service Perimeter to add this resource to.
- resource str
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
- perimeter
Name String The name of the Service Perimeter to add this resource to.
- resource String
A GCP resource that is inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}
Import
ServicePerimeterResource can be imported using any of these accepted formats
$ pulumi import gcp:accesscontextmanager/servicePerimeterResource:ServicePerimeterResource default {{perimeter_name}}/{{resource}}
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.