cloudfoundry.NetworkPolicy
Explore with Pulumi AI
Provides a Cloud Foundry resource for managing Cloud Foundry network policies to manage access between applications via container-to-container networking.
Example Usage
The following creates container to container access policy between the given applications.
import * as pulumi from "@pulumi/pulumi";
import * as cloudfoundry from "@pulumi/cloudfoundry";
const my_policy = new cloudfoundry.NetworkPolicy("my-policy", {policies: [
{
sourceApp: cloudfoundry_app.app1.id,
destinationApp: cloudfoundry_app.app2.id,
port: "8080-8090",
},
{
sourceApp: cloudfoundry_app.app1.id,
destinationApp: cloudfoundry_app.app3.id,
port: "9999",
protocol: "udp",
},
]});
import pulumi
import pulumi_cloudfoundry as cloudfoundry
my_policy = cloudfoundry.NetworkPolicy("my-policy", policies=[
{
"source_app": cloudfoundry_app["app1"]["id"],
"destination_app": cloudfoundry_app["app2"]["id"],
"port": "8080-8090",
},
{
"source_app": cloudfoundry_app["app1"]["id"],
"destination_app": cloudfoundry_app["app3"]["id"],
"port": "9999",
"protocol": "udp",
},
])
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/cloudfoundry/cloudfoundry"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := cloudfoundry.NewNetworkPolicy(ctx, "my-policy", &cloudfoundry.NetworkPolicyArgs{
Policies: cloudfoundry.NetworkPolicyPolicyArray{
&cloudfoundry.NetworkPolicyPolicyArgs{
SourceApp: pulumi.Any(cloudfoundry_app.App1.Id),
DestinationApp: pulumi.Any(cloudfoundry_app.App2.Id),
Port: pulumi.String("8080-8090"),
},
&cloudfoundry.NetworkPolicyPolicyArgs{
SourceApp: pulumi.Any(cloudfoundry_app.App1.Id),
DestinationApp: pulumi.Any(cloudfoundry_app.App3.Id),
Port: pulumi.String("9999"),
Protocol: pulumi.String("udp"),
},
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Cloudfoundry = Pulumi.Cloudfoundry;
return await Deployment.RunAsync(() =>
{
var my_policy = new Cloudfoundry.NetworkPolicy("my-policy", new()
{
Policies = new[]
{
new Cloudfoundry.Inputs.NetworkPolicyPolicyArgs
{
SourceApp = cloudfoundry_app.App1.Id,
DestinationApp = cloudfoundry_app.App2.Id,
Port = "8080-8090",
},
new Cloudfoundry.Inputs.NetworkPolicyPolicyArgs
{
SourceApp = cloudfoundry_app.App1.Id,
DestinationApp = cloudfoundry_app.App3.Id,
Port = "9999",
Protocol = "udp",
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.cloudfoundry.NetworkPolicy;
import com.pulumi.cloudfoundry.NetworkPolicyArgs;
import com.pulumi.cloudfoundry.inputs.NetworkPolicyPolicyArgs;
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 my_policy = new NetworkPolicy("my-policy", NetworkPolicyArgs.builder()
.policies(
NetworkPolicyPolicyArgs.builder()
.sourceApp(cloudfoundry_app.app1().id())
.destinationApp(cloudfoundry_app.app2().id())
.port("8080-8090")
.build(),
NetworkPolicyPolicyArgs.builder()
.sourceApp(cloudfoundry_app.app1().id())
.destinationApp(cloudfoundry_app.app3().id())
.port("9999")
.protocol("udp")
.build())
.build());
}
}
resources:
my-policy:
type: cloudfoundry:NetworkPolicy
properties:
policies:
- sourceApp: ${cloudfoundry_app.app1.id}
destinationApp: ${cloudfoundry_app.app2.id}
port: 8080-8090
- sourceApp: ${cloudfoundry_app.app1.id}
destinationApp: ${cloudfoundry_app.app3.id}
port: '9999'
protocol: udp
Create NetworkPolicy Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new NetworkPolicy(name: string, args?: NetworkPolicyArgs, opts?: CustomResourceOptions);
@overload
def NetworkPolicy(resource_name: str,
args: Optional[NetworkPolicyArgs] = None,
opts: Optional[ResourceOptions] = None)
@overload
def NetworkPolicy(resource_name: str,
opts: Optional[ResourceOptions] = None,
network_policy_id: Optional[str] = None,
policies: Optional[Sequence[NetworkPolicyPolicyArgs]] = None)
func NewNetworkPolicy(ctx *Context, name string, args *NetworkPolicyArgs, opts ...ResourceOption) (*NetworkPolicy, error)
public NetworkPolicy(string name, NetworkPolicyArgs? args = null, CustomResourceOptions? opts = null)
public NetworkPolicy(String name, NetworkPolicyArgs args)
public NetworkPolicy(String name, NetworkPolicyArgs args, CustomResourceOptions options)
type: cloudfoundry:NetworkPolicy
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args NetworkPolicyArgs
- 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 NetworkPolicyArgs
- 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 NetworkPolicyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args NetworkPolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args NetworkPolicyArgs
- 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 networkPolicyResource = new Cloudfoundry.NetworkPolicy("networkPolicyResource", new()
{
NetworkPolicyId = "string",
Policies = new[]
{
new Cloudfoundry.Inputs.NetworkPolicyPolicyArgs
{
DestinationApp = "string",
Port = "string",
SourceApp = "string",
Protocol = "string",
},
},
});
example, err := cloudfoundry.NewNetworkPolicy(ctx, "networkPolicyResource", &cloudfoundry.NetworkPolicyArgs{
NetworkPolicyId: pulumi.String("string"),
Policies: cloudfoundry.NetworkPolicyPolicyArray{
&cloudfoundry.NetworkPolicyPolicyArgs{
DestinationApp: pulumi.String("string"),
Port: pulumi.String("string"),
SourceApp: pulumi.String("string"),
Protocol: pulumi.String("string"),
},
},
})
var networkPolicyResource = new NetworkPolicy("networkPolicyResource", NetworkPolicyArgs.builder()
.networkPolicyId("string")
.policies(NetworkPolicyPolicyArgs.builder()
.destinationApp("string")
.port("string")
.sourceApp("string")
.protocol("string")
.build())
.build());
network_policy_resource = cloudfoundry.NetworkPolicy("networkPolicyResource",
network_policy_id="string",
policies=[{
"destination_app": "string",
"port": "string",
"source_app": "string",
"protocol": "string",
}])
const networkPolicyResource = new cloudfoundry.NetworkPolicy("networkPolicyResource", {
networkPolicyId: "string",
policies: [{
destinationApp: "string",
port: "string",
sourceApp: "string",
protocol: "string",
}],
});
type: cloudfoundry:NetworkPolicy
properties:
networkPolicyId: string
policies:
- destinationApp: string
port: string
protocol: string
sourceApp: string
NetworkPolicy 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 NetworkPolicy resource accepts the following input properties:
- Network
Policy stringId - The GUID of the network_policy
- Policies
List<Network
Policy Policy> - List of policies that allow direct network traffic from one app to another.
- Network
Policy stringId - The GUID of the network_policy
- Policies
[]Network
Policy Policy Args - List of policies that allow direct network traffic from one app to another.
- network
Policy StringId - The GUID of the network_policy
- policies
List<Network
Policy Policy> - List of policies that allow direct network traffic from one app to another.
- network
Policy stringId - The GUID of the network_policy
- policies
Network
Policy Policy[] - List of policies that allow direct network traffic from one app to another.
- network_
policy_ strid - The GUID of the network_policy
- policies
Sequence[Network
Policy Policy Args] - List of policies that allow direct network traffic from one app to another.
- network
Policy StringId - The GUID of the network_policy
- policies List<Property Map>
- List of policies that allow direct network traffic from one app to another.
Outputs
All input properties are implicitly available as output properties. Additionally, the NetworkPolicy 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 NetworkPolicy Resource
Get an existing NetworkPolicy 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?: NetworkPolicyState, opts?: CustomResourceOptions): NetworkPolicy
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
network_policy_id: Optional[str] = None,
policies: Optional[Sequence[NetworkPolicyPolicyArgs]] = None) -> NetworkPolicy
func GetNetworkPolicy(ctx *Context, name string, id IDInput, state *NetworkPolicyState, opts ...ResourceOption) (*NetworkPolicy, error)
public static NetworkPolicy Get(string name, Input<string> id, NetworkPolicyState? state, CustomResourceOptions? opts = null)
public static NetworkPolicy get(String name, Output<String> id, NetworkPolicyState state, CustomResourceOptions options)
resources: _: type: cloudfoundry:NetworkPolicy get: id: ${id}
- 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.
- Network
Policy stringId - The GUID of the network_policy
- Policies
List<Network
Policy Policy> - List of policies that allow direct network traffic from one app to another.
- Network
Policy stringId - The GUID of the network_policy
- Policies
[]Network
Policy Policy Args - List of policies that allow direct network traffic from one app to another.
- network
Policy StringId - The GUID of the network_policy
- policies
List<Network
Policy Policy> - List of policies that allow direct network traffic from one app to another.
- network
Policy stringId - The GUID of the network_policy
- policies
Network
Policy Policy[] - List of policies that allow direct network traffic from one app to another.
- network_
policy_ strid - The GUID of the network_policy
- policies
Sequence[Network
Policy Policy Args] - List of policies that allow direct network traffic from one app to another.
- network
Policy StringId - The GUID of the network_policy
- policies List<Property Map>
- List of policies that allow direct network traffic from one app to another.
Supporting Types
NetworkPolicyPolicy, NetworkPolicyPolicyArgs
- Destination
App string - The ID of the application to connect to.
- Port string
- Port (8080) or range of ports (8080-8085) for connection to destination app
- Source
App string - The ID of the application to connect from.
- Protocol string
- One of 'udp' or 'tcp' identifying the allowed protocol for the access. Default is 'tcp'.
- Destination
App string - The ID of the application to connect to.
- Port string
- Port (8080) or range of ports (8080-8085) for connection to destination app
- Source
App string - The ID of the application to connect from.
- Protocol string
- One of 'udp' or 'tcp' identifying the allowed protocol for the access. Default is 'tcp'.
- destination
App String - The ID of the application to connect to.
- port String
- Port (8080) or range of ports (8080-8085) for connection to destination app
- source
App String - The ID of the application to connect from.
- protocol String
- One of 'udp' or 'tcp' identifying the allowed protocol for the access. Default is 'tcp'.
- destination
App string - The ID of the application to connect to.
- port string
- Port (8080) or range of ports (8080-8085) for connection to destination app
- source
App string - The ID of the application to connect from.
- protocol string
- One of 'udp' or 'tcp' identifying the allowed protocol for the access. Default is 'tcp'.
- destination_
app str - The ID of the application to connect to.
- port str
- Port (8080) or range of ports (8080-8085) for connection to destination app
- source_
app str - The ID of the application to connect from.
- protocol str
- One of 'udp' or 'tcp' identifying the allowed protocol for the access. Default is 'tcp'.
- destination
App String - The ID of the application to connect to.
- port String
- Port (8080) or range of ports (8080-8085) for connection to destination app
- source
App String - The ID of the application to connect from.
- protocol String
- One of 'udp' or 'tcp' identifying the allowed protocol for the access. Default is 'tcp'.
Import
The current Network policy can be imported using the network_policy
, e.g.
bash
$ pulumi import cloudfoundry:index/networkPolicy:NetworkPolicy my-policy a-guid
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- cloudfoundry cloudfoundry-community/terraform-provider-cloudfoundry
- License
- Notes
- This Pulumi package is based on the
cloudfoundry
Terraform Provider.