Skip to main content

Get

Returns the specified SecurityGroup resource.

To get the list of all available SecurityGroup resources, make a List request.

import { cloudApi, serviceClients, Session } from "@yandex-cloud/nodejs-sdk";

const GetSecurityGroupRequest =
cloudApi.vpc.security_group_service.GetSecurityGroupRequest;

(async () => {
const authToken = process.env["YC_OAUTH_TOKEN"];
const session = new Session({ oauthToken: authToken });
const client = session.client(serviceClients.SecurityGroupServiceClient);

const result = await client.get(
GetSecurityGroupRequest.fromPartial({
securityGroupId: "securityGroupId",
})
);
console.log(result);
})();

GetSecurityGroupRequest

securityGroupId : string

ID of the Security Group resource to return. To get the security group ID, use a SecurityGroup.List request.

SecurityGroup

Status

  • STATUS_UNSPECIFIED

  • CREATING

    Security group is being created.

  • ACTIVE

    Security is active and it's rules are applied to the network interfaces.

  • UPDATING

    Security group is updating. Updating is a long operation because we must update all instances in SG.

  • DELETING

    Instance is being deleted.

id : string

ID of the security group.

folderId : string

ID of the folder that the security group belongs to.

createdAt : google.protobuf.Timestamp

Creation timestamp in RFC3339 text format.

name : string

Name of the security group. The name must be unique within the folder. Value must match the regular expression \|[a-zA-Z]([-_a-zA-Z0-9]{0,61}[a-zA-Z0-9])?.

description : string

Description of the security group. 0-256 characters long.

labels : string

Resource labels as key:value pairs. No more than 64 per resource. The maximum string length in characters for each value is 63. Each value must match the regular expression [-_./\\@0-9a-z]*. The string length in characters for each key must be 1-63. Each key must match the regular expression [a-z][-_./\\@0-9a-z]*.

networkId : string

ID of the network that the security group belongs to.

status : Status

Security group status.

rules : SecurityGroupRule

List of the security group rules.

defaultForNetwork : bool

Flag that indicates that the security group is the default for the network.

SecurityGroupRule

Direction
  • DIRECTION_UNSPECIFIED

  • INGRESS

    Allows ingress traffic.

  • EGRESS

    Allows egress traffic.

id : string

ID of the rule.

description : string

Description of the rule. 0-256 characters long.

labels : string

Resource labels as key:value pairs. Maximum of 64 per resource.

direction : Direction

The direction of network traffic allowed by this rule.

ports : PortRange

The range of ports that allow traffic to pass through. Null value means any.

protocolName : string

Protocol name. Null value means any protocol. Values from IANA.

protocolNumber : int64

Protocol number from IANA protocol numbers.

One of target

  • cidrBlocks : CidrBlocks

    CIDR blocks to allow to recieve or send traffic.

  • securityGroupId : string

    ID of the security group to add rule to.

  • predefinedTarget : string

    Predefined target. See security groups rules for more information.

PortRange

fromPort : int64

The lowest port in the range.

toPort : int64

The highest port in the range.

CidrBlocks

v4CidrBlocks : string

IPv4 CIDR blocks to allow traffic to.

v6CidrBlocks : string

IPv6 CIDR blocks to allow traffic to.