Amazon AWS SDK Betriebsanweisung Seite 44

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 73
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 43
FromPort and ToPort
The beginning and end of the port range.This example specifies a single port, 3389, which is
used to communicate with Windows over RDP.
IpRanges
The IP addresses or address ranges, in CIDR notation. For convenience, this example uses
0.0.0.0/0, which authorizes network traffic from all IP addresses.This is acceptable for a short
time in a test environment, but it's unsafe in a production environment.
2. Create and initialize an AuthorizeSecurityGroupIngressRequest object.
var ingressRequest = new AuthorizeSecurityGroupIngressRequest();
ingressRequest.GroupId = mySG.GroupId;
ingressRequest.IpPermissions.Add(ipPermission);
GroupId
The ID of the security group.
IpPermissions
The IpPermission object from step 1.
3. (Optional) You can add additional rules to the IpPermissions collection before going to the next
step.
4. Pass the request object to the AuthorizeSecurityGroupIngress method, which returns an AuthorizeSe-
curityGroupIngressResponse object.
var ingressResponse = ec2Client.AuthorizeSecurityGroupIngress(ingress
Request);
Console.WriteLine("New RDP rule for: " + ipRange);
Create a Key Pair Using the SDK for .NET
You must specify a key pair when you launch an EC2 instance and specify the private key of the key pair
when you connect to the instance.You can create a key pair or use an existing key pair that you've used
when launching other instances. For more information, see Amazon EC2 Key Pairs in the Amazon
Elastic Compute Cloud User Guide for Microsoft Windows.
Enumerating Your Key Pairs
You can enumerate your key pairs and check whether a particular key pair exists.
To enumerate your key pairs
Get the complete list of your key pairs using DescribeKeyPairs with no parameters.The following example
checks each key pair to see whether its name is my-sample-key.
string keyPairName = "my-sample-key";
KeyPairInfo myKeyPair = null;
var dkpRequest = new DescribeKeyPairsRequest();
var dkpResponse = ec2Client.DescribeKeyPairs(dkpRequest);
List<KeyPairInfo> myKeyPairs = dkpResponse.KeyPairs;
Version v2.0.0
40
AWS SDK for .NET Developer Guide
Create a Key Pair
Seitenansicht 43
1 2 ... 39 40 41 42 43 44 45 46 47 48 49 ... 72 73

Kommentare zu diesen Handbüchern

Keine Kommentare