Amazon AWS SDK Betriebsanweisung Seite 41

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 73
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 40
Create a Security Group Using the SDK for .NET
Create a security group, which acts as a virtual firewall that controls the network traffic for one or more
EC2 instances. By default, Amazon EC2 associates your instances with a security group that allows no
inbound traffic.You can create a security group that allows your EC2 instances to accept certain traffic.
For example, if you need to connect to an EC2 Windows instance, you must configure the security group
to allow RDP traffic.You can create a security group using the Amazon EC2 console or the SDK for .NET.
You create a security group for use in either EC2-Classic or EC2-VPC. For more information about EC2-
Classic and EC2-VPC, see Supported Platforms in the Amazon Elastic Compute Cloud User Guide for
Microsoft Windows.
Alternatively, you can create a security group using the Amazon EC2 console. For more information, see
Amazon EC2 Security Groups in the Amazon Elastic Compute Cloud User Guide for Microsoft Windows.
Contents
Enumerating Your Security Groups (p. 37)
Creating a Security Group (p. 38)
Adding Rules to Your Security Group (p. 39)
Enumerating Your Security Groups
You can enumerate your security groups and check whether a particular security group exists.
To enumerate your security groups
Get the complete list of your security groups using DescribeSecurityGroups with no parameters. The
following example checks each security group to see whether its name is my-sample-sg.
string secGroupName = "my-sample-sg";
SecurityGroup mySG = null;
var dsgRequest = new DescribeSecurityGroupsRequest();
var dsgResponse = ec2Client.DescribeSecurityGroups(dsgRequest);
List<SecurityGroup> mySGs = dsgResponse.SecurityGroups;
foreach (SecurityGroup item in mySGs)
{
Console.WriteLine("Existing security group: " + item.GroupId);
if (item.GroupName == secGroupName)
{
mySG = item;
}
}
To enumerate your security groups for a VPC
To enumerate the security groups for a particular VPC, use DescribeSecurityGroups with a filter.The
following example checks each security group for a security group with the name my-sample-sg-vpc.
string secGroupName = "my-sample-sg-vpc";
SecurityGroup mySG = null;
string vpcID = "vpc-f1663d98";
Filter vpcFilter = new Filter
Version v2.0.0
37
AWS SDK for .NET Developer Guide
Create a Security Group
Seitenansicht 40
1 2 ... 36 37 38 39 40 41 42 43 44 45 46 ... 72 73

Kommentare zu diesen Handbüchern

Keine Kommentare