Skip to content

Commit

Permalink
updated POM
Browse files Browse the repository at this point in the history
  • Loading branch information
scmacdon committed Feb 14, 2024
1 parent 22e1bc5 commit de8d84f
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 129 deletions.
2 changes: 1 addition & 1 deletion javav2/example_code/cloudtrail/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.21.20</version>
<version>2.23.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion javav2/example_code/cloudwatch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.21.20</version>
<version>2.23.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion javav2/example_code/codedeploy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.21.20</version>
<version>2.23.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion javav2/example_code/codepipeline/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.21.20</version>
<version>2.23.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion javav2/example_code/cognito/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.21.20</version>
<version>2.23.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion javav2/example_code/comprehend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.21.20</version>
<version>2.23.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion javav2/example_code/connect/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.21.20</version>
<version>2.23.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion javav2/example_code/dynamodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.21.20</version>
<version>2.23.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion javav2/example_code/ec2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.21.20</version>
<version>2.23.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
121 changes: 2 additions & 119 deletions javav2/example_code/ec2/src/test/java/EC2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import software.amazon.awssdk.services.ec2.Ec2Client;
import java.io.*;
import java.util.concurrent.TimeUnit;

import java.util.Random;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient;
import software.amazon.awssdk.services.secretsmanager.model.GetSecretValueRequest;
Expand Down Expand Up @@ -64,7 +64,7 @@ public static void setUp() throws IOException {
ami = values.getAmi();
instanceName = values.getInstanceName();
keyName = values.getKeyNameSc();
groupName = values.getGroupName();
groupName = values.getGroupName() + java.util.UUID.randomUUID();;
groupDesc = values.getGroupDesc();
vpcId = values.getVpcId();
keyNameSc = values.getKeyNameSc() + java.util.UUID.randomUUID();
Expand Down Expand Up @@ -218,123 +218,6 @@ public void TerminateInstance() {
System.out.println("\n Test 14 passed");
}

@Test
@Tag("IntegrationTest")
@Order(15)
public void TestEC2Scenario() throws InterruptedException {
System.out.println(EC2Scenario.DASHES);
System.out.println("1. Create an RSA key pair and save the private key material as a .pem file.");
EC2Scenario.createKeyPair(ec2, keyNameSc, fileNameSc);
System.out.println(EC2Scenario.DASHES);

System.out.println(EC2Scenario.DASHES);
System.out.println("2. List key pairs.");
EC2Scenario.describeKeys(ec2);
System.out.println(EC2Scenario.DASHES);

System.out.println(EC2Scenario.DASHES);
System.out.println("3. Create a security group.");
String groupId = EC2Scenario.createSecurityGroup(ec2, groupNameSc, groupDescSc, vpcIdSc, myIpAddressSc);
assertFalse(groupId.isEmpty());
System.out.println(EC2Scenario.DASHES);

System.out.println(EC2Scenario.DASHES);
System.out.println("4. Display security group info for the newly created security group.");
EC2Scenario.describeSecurityGroups(ec2, groupId);
System.out.println(EC2Scenario.DASHES);

System.out.println(EC2Scenario.DASHES);
System.out.println("5. Get a list of Amazon Linux 2 AMIs and select one with amzn2 in the name.");
String instanceId = EC2Scenario.getParaValues(ssmClient);
assertFalse(instanceId.isEmpty());
System.out.println("The instance Id is " + instanceId);
System.out.println(EC2Scenario.DASHES);

System.out.println(EC2Scenario.DASHES);
System.out.println("6. Get more information about an amzn2 image.");
String amiValue = EC2Scenario.describeImage(ec2, instanceId);
assertFalse(amiValue.isEmpty());
System.out.println(EC2Scenario.DASHES);

System.out.println(EC2Scenario.DASHES);
System.out.println("7. Get a list of instance types.");
String instanceType = EC2Scenario.getInstanceTypes(ec2);
assertFalse(instanceType.isEmpty());
if (instanceType.compareTo("x2gd.metal") != 0)
instanceType = "x2gd.metal";
System.out.println("*** The instance type is " + instanceType);
System.out.println(EC2Scenario.DASHES);

System.out.println(EC2Scenario.DASHES);
System.out.println("Wait 1 min before creating the instance using " + instanceType);
TimeUnit.MINUTES.sleep(1);
System.out.println("8. Create an instance.");
String newInstanceId = EC2Scenario.runInstance(ec2, instanceType, keyNameSc, groupNameSc, amiValue);
System.out.println("The instance Id is " + newInstanceId);
System.out.println(EC2Scenario.DASHES);

System.out.println(EC2Scenario.DASHES);
System.out.println("9. Display information about the running instance. ");
String ipAddress = EC2Scenario.describeEC2Instances(ec2, newInstanceId);
assertFalse(ipAddress.isEmpty());
System.out.println("You can SSH to the instance using this command:");
System.out.println("ssh -i " + fileNameSc + "ec2-user@" + ipAddress);
System.out.println(EC2Scenario.DASHES);

System.out.println(EC2Scenario.DASHES);
System.out.println("10. Stop the instance.");
EC2Scenario.stopInstance(ec2, newInstanceId);
System.out.println(EC2Scenario.DASHES);

System.out.println(EC2Scenario.DASHES);
System.out.println("11. Start the instance.");
EC2Scenario.startInstance(ec2, newInstanceId);
ipAddress = EC2Scenario.describeEC2Instances(ec2, newInstanceId);
assertFalse(ipAddress.isEmpty());
System.out.println("You can SSH to the instance using this command:");
System.out.println("ssh -i " + fileNameSc + "ec2-user@" + ipAddress);
System.out.println(EC2Scenario.DASHES);

System.out.println(EC2Scenario.DASHES);
System.out.println("12. Allocate an Elastic IP address and associate it with the instance.");
String allocationId = EC2Scenario.allocateAddress(ec2);
assertFalse(allocationId.isEmpty());
System.out.println("The allocation Id value is " + allocationId);
String associationId = EC2Scenario.associateAddress(ec2, newInstanceId, allocationId);
System.out.println("The association Id value is " + associationId);
System.out.println(EC2Scenario.DASHES);

System.out.println(EC2Scenario.DASHES);
System.out.println("13. Describe the instance again.");
ipAddress = EC2Scenario.describeEC2Instances(ec2, newInstanceId);
assertFalse(ipAddress.isEmpty());
System.out.println("You can SSH to the instance using this command:");
System.out.println("ssh -i " + fileNameSc + "ec2-user@" + ipAddress);
System.out.println(EC2Scenario.DASHES);

System.out.println(EC2Scenario.DASHES);
System.out.println("14. Disassociate and release the Elastic IP address.");
EC2Scenario.disassociateAddress(ec2, associationId);
EC2Scenario.releaseEC2Address(ec2, allocationId);
System.out.println(EC2Scenario.DASHES);

System.out.println(EC2Scenario.DASHES);
System.out.println("15. Terminate the instance.");
EC2Scenario.terminateEC2(ec2, newInstanceId);
System.out.println(EC2Scenario.DASHES);

System.out.println(EC2Scenario.DASHES);
System.out.println("16. Delete the security group.");
EC2Scenario.deleteEC2SecGroup(ec2, groupId);
System.out.println(EC2Scenario.DASHES);

System.out.println(EC2Scenario.DASHES);
System.out.println("17. Delete the keys.");
EC2Scenario.deleteKeys(ec2, keyNameSc);
System.out.println(EC2Scenario.DASHES);
System.out.println("\n Test 16 passed");
}

private static String getSecretValues() {
SecretsManagerClient secretClient = SecretsManagerClient.builder()
.region(Region.US_EAST_1)
Expand Down
2 changes: 1 addition & 1 deletion javav2/example_code/ecs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.21.20</version>
<version>2.23.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down

0 comments on commit de8d84f

Please sign in to comment.