@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
134 lines • 4.57 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSubnetOutput = exports.getSubnet = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* `aws.ec2.Subnet` provides details about a specific VPC subnet.
*
* This resource can prove useful when a module accepts a subnet ID as an input variable and needs to, for example, determine the ID of the VPC that the subnet belongs to.
*
* ## Example Usage
*
* The following example shows how one might accept a subnet ID as a variable and use this data source to obtain the data necessary to create a security group that allows connections from hosts in that subnet.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const config = new pulumi.Config();
* const subnetId = config.requireObject<any>("subnetId");
* const selected = aws.ec2.getSubnet({
* id: subnetId,
* });
* const subnetSecurityGroup = new aws.ec2.SecurityGroup("subnet_security_group", {
* vpcId: selected.then(selected => selected.vpcId),
* ingress: [{
* cidrBlocks: [selected.then(selected => selected.cidrBlock)],
* fromPort: 80,
* toPort: 80,
* protocol: "tcp",
* }],
* });
* ```
*
* ### Filter Example
*
* If you want to match against tag `Name`, use:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const selected = aws.ec2.getSubnet({
* filters: [{
* name: "tag:Name",
* values: ["yakdriver"],
* }],
* });
* ```
*/
function getSubnet(args, opts) {
args = args || {};
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts || {});
return pulumi.runtime.invoke("aws:ec2/getSubnet:getSubnet", {
"availabilityZone": args.availabilityZone,
"availabilityZoneId": args.availabilityZoneId,
"cidrBlock": args.cidrBlock,
"defaultForAz": args.defaultForAz,
"filters": args.filters,
"id": args.id,
"ipv6CidrBlock": args.ipv6CidrBlock,
"region": args.region,
"state": args.state,
"tags": args.tags,
"vpcId": args.vpcId,
}, opts);
}
exports.getSubnet = getSubnet;
/**
* `aws.ec2.Subnet` provides details about a specific VPC subnet.
*
* This resource can prove useful when a module accepts a subnet ID as an input variable and needs to, for example, determine the ID of the VPC that the subnet belongs to.
*
* ## Example Usage
*
* The following example shows how one might accept a subnet ID as a variable and use this data source to obtain the data necessary to create a security group that allows connections from hosts in that subnet.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const config = new pulumi.Config();
* const subnetId = config.requireObject<any>("subnetId");
* const selected = aws.ec2.getSubnet({
* id: subnetId,
* });
* const subnetSecurityGroup = new aws.ec2.SecurityGroup("subnet_security_group", {
* vpcId: selected.then(selected => selected.vpcId),
* ingress: [{
* cidrBlocks: [selected.then(selected => selected.cidrBlock)],
* fromPort: 80,
* toPort: 80,
* protocol: "tcp",
* }],
* });
* ```
*
* ### Filter Example
*
* If you want to match against tag `Name`, use:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const selected = aws.ec2.getSubnet({
* filters: [{
* name: "tag:Name",
* values: ["yakdriver"],
* }],
* });
* ```
*/
function getSubnetOutput(args, opts) {
args = args || {};
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts || {});
return pulumi.runtime.invokeOutput("aws:ec2/getSubnet:getSubnet", {
"availabilityZone": args.availabilityZone,
"availabilityZoneId": args.availabilityZoneId,
"cidrBlock": args.cidrBlock,
"defaultForAz": args.defaultForAz,
"filters": args.filters,
"id": args.id,
"ipv6CidrBlock": args.ipv6CidrBlock,
"region": args.region,
"state": args.state,
"tags": args.tags,
"vpcId": args.vpcId,
}, opts);
}
exports.getSubnetOutput = getSubnetOutput;
//# sourceMappingURL=getSubnet.js.map