-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
233 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# AWS Batch code examples for the SDK for Java 2.x | ||
|
||
## Overview | ||
|
||
Shows how to use the AWS SDK for Java 2.x to work with AWS Batch. | ||
|
||
<!--custom.overview.start--> | ||
<!--custom.overview.end--> | ||
|
||
_AWS Batch enables you to run batch computing workloads on the AWS Cloud._ | ||
|
||
## ⚠ Important | ||
|
||
* Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/) and [Free Tier](https://aws.amazon.com/free/). | ||
* Running the tests might result in charges to your AWS account. | ||
* We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege). | ||
* This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services). | ||
|
||
<!--custom.important.start--> | ||
<!--custom.important.end--> | ||
|
||
## Code examples | ||
|
||
### Prerequisites | ||
|
||
For prerequisites, see the [README](../../README.md#Prerequisites) in the `javav2` folder. | ||
|
||
|
||
<!--custom.prerequisites.start--> | ||
<!--custom.prerequisites.end--> | ||
|
||
### Get started | ||
|
||
- [Hello AWS Batch](src/main/java/com/example/batch/HelloBatch.java#L6) (`listJobsPaginator`) | ||
|
||
|
||
### Single actions | ||
|
||
Code excerpts that show you how to call individual service functions. | ||
|
||
- [CreateComputeEnvironment](src/main/java/com/example/batch/scenario/BatchActions.java#L102) | ||
- [CreateJobQueue](src/main/java/com/example/batch/scenario/BatchActions.java#L193) | ||
- [DeleteComputeEnvironment](src/main/java/com/example/batch/scenario/BatchActions.java#L142) | ||
- [DeleteJobQueue](src/main/java/com/example/batch/scenario/BatchActions.java#L370) | ||
- [DeregisterJobDefinition](src/main/java/com/example/batch/scenario/BatchActions.java#L323) | ||
- [DescribeComputeEnvironments](src/main/java/com/example/batch/scenario/BatchActions.java#L162) | ||
- [DescribeJobQueues](src/main/java/com/example/batch/scenario/BatchActions.java#L394) | ||
- [DescribeJobs](src/main/java/com/example/batch/scenario/BatchActions.java#L490) | ||
- [ListJobsPaginator](src/main/java/com/example/batch/scenario/BatchActions.java#L230) | ||
- [RegisterJobDefinition](src/main/java/com/example/batch/scenario/BatchActions.java#L257) | ||
- [SubmitJob](src/main/java/com/example/batch/scenario/BatchActions.java#L463) | ||
- [UpdateComputeEnvironment](src/main/java/com/example/batch/scenario/BatchActions.java#L439) | ||
- [UpdateJobQueue](src/main/java/com/example/batch/scenario/BatchActions.java#L347) | ||
|
||
### Scenarios | ||
|
||
Code examples that show you how to accomplish a specific task by calling multiple | ||
functions within the same service. | ||
|
||
- [Learn AWS Batch core operations](src/main/java/com/example/batch/scenario/BatchScenario.java) | ||
|
||
|
||
<!--custom.examples.start--> | ||
<!--custom.examples.end--> | ||
|
||
## Run the examples | ||
|
||
### Instructions | ||
|
||
|
||
<!--custom.instructions.start--> | ||
<!--custom.instructions.end--> | ||
|
||
#### Hello AWS Batch | ||
|
||
This example shows you how to get started using AWS Batch. | ||
|
||
|
||
|
||
#### Learn AWS Batch core operations | ||
|
||
This example shows you how to do the following: | ||
|
||
- Create an AWS Batch compute environment. | ||
- Check the status of the compute environment. | ||
- Set up an AWS Batch job queue and job definition. | ||
- Register a job definition. | ||
- Submit an AWS Batch Job. | ||
- Get a list of jobs applicable to the job queue. | ||
- Check the status of job. | ||
- Delete AWS Batch resources. | ||
|
||
<!--custom.scenario_prereqs.batch_Scenario.start--> | ||
<!--custom.scenario_prereqs.batch_Scenario.end--> | ||
|
||
|
||
<!--custom.scenarios.batch_Scenario.start--> | ||
<!--custom.scenarios.batch_Scenario.end--> | ||
|
||
### Tests | ||
|
||
⚠ Running tests might result in charges to your AWS account. | ||
|
||
|
||
To find instructions for running these tests, see the [README](../../README.md#Tests) | ||
in the `javav2` folder. | ||
|
||
|
||
|
||
<!--custom.tests.start--> | ||
<!--custom.tests.end--> | ||
|
||
## Additional resources | ||
|
||
- [AWS Batch User Guide](https://docs.aws.amazon.com/batch/latest/userguide/what-is-batch.html) | ||
- [AWS Batch API Reference](https://docs.aws.amazon.com/batch/latest/APIReference/Welcome.html) | ||
- [SDK for Java 2.x AWS Batch reference](https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/ec2/package-summary.html) | ||
|
||
<!--custom.resources.start--> | ||
<!--custom.resources.end--> | ||
|
||
--- | ||
|
||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
|
||
SPDX-License-Identifier: Apache-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
import com.example.acm.AddTagsToCertificate; | ||
import com.example.acm.DeleteCert; | ||
import com.example.acm.DescribeCert; | ||
import com.example.acm.ImportCert; | ||
import com.example.acm.ListCertTags; | ||
import com.example.acm.RemoveTagsFromCert; | ||
import com.example.acm.RequestCert; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.MethodOrderer; | ||
import org.junit.jupiter.api.Order; | ||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.junit.jupiter.api.TestMethodOrder; | ||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_METHOD) | ||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) | ||
public class ACMTests { | ||
|
||
private static String certificatePath = ""; | ||
private static String privateKeyPath = ""; | ||
|
||
private static String certificateArn; | ||
|
||
@BeforeAll | ||
public static void setUp() { | ||
|
||
certificatePath = "C:\\Users\\scmacdon\\cert_example\\certificate.pem"; | ||
privateKeyPath = "C:\\Users\\scmacdon\\cert_example\\private_key.pem"; | ||
} | ||
|
||
@Test | ||
@Tag("IntegrationTest") | ||
@Order(1) | ||
public void testImportCert() { | ||
assertDoesNotThrow(() -> { | ||
certificateArn = ImportCert.importCertificate(certificatePath, privateKeyPath); | ||
assertNotNull(certificateArn); | ||
}); | ||
} | ||
|
||
@Test | ||
@Tag("IntegrationTest") | ||
@Order(2) | ||
public void testAddTags() { | ||
assertDoesNotThrow(() -> { | ||
AddTagsToCertificate.addTags(certificateArn); | ||
}); | ||
} | ||
|
||
@Test | ||
@Tag("IntegrationTest") | ||
@Order(3) | ||
public void testDescribeCert() { | ||
assertDoesNotThrow(() -> { | ||
DescribeCert.describeCertificate(certificateArn); | ||
}); | ||
} | ||
|
||
@Test | ||
@Tag("IntegrationTest") | ||
@Order(4) | ||
public void testListCertTags() { | ||
assertDoesNotThrow(() -> { | ||
ListCertTags.listCertTags(certificateArn); | ||
}); | ||
} | ||
|
||
@Test | ||
@Tag("IntegrationTest") | ||
@Order(5) | ||
public void testRemoveTagsFromCert() { | ||
assertDoesNotThrow(() -> { | ||
RemoveTagsFromCert.removeTags(certificateArn); | ||
}); | ||
} | ||
|
||
|
||
@Test | ||
@Tag("IntegrationTest") | ||
@Order(6) | ||
public void testRequestCert() { | ||
assertDoesNotThrow(() -> { | ||
RequestCert.requestCertificate(); | ||
}); | ||
} | ||
|
||
@Test | ||
@Tag("IntegrationTest") | ||
@Order(7) | ||
public void testDeleteCert() { | ||
assertDoesNotThrow(() -> { | ||
DeleteCert.deleteCertificate(certificateArn); | ||
}); | ||
} | ||
} |