Skip to content

Commit

Permalink
Use Env for Creds
Browse files Browse the repository at this point in the history
  • Loading branch information
vasireddy99 committed Oct 5, 2023
1 parent 67513b4 commit be4d18f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
1 change: 0 additions & 1 deletion adot-testbed/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@ application {
tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
systemProperty("adot.testbed.localcreds", System.getProperty("adot.testbed.localcreds"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
@Testcontainers(disabledWithoutDocker = true)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class LogsTests {
private static final String LOCAL_CREDENTIALS = System.getProperty("adot.testbed.localcreds");
private static final String TEST_IMAGE = System.getenv("TEST_IMAGE") != null && !System.getenv("TEST_IMAGE").isEmpty()
? System.getenv("TEST_IMAGE")
: "public.ecr.aws/aws-otel-test/adot-collector-integration-test:latest";
Expand All @@ -58,6 +57,11 @@ private GenericContainer<?> createAndStartCollector(String configFilePath, Strin
// Create an environment variable map
Map<String, String> envVariables = new HashMap<>();
envVariables.put("LOG_STREAM_NAME", uniqueLogStreamName);
//Set credentials
envVariables.put("AWS_REGION", System.getenv("AWS_REGION"));
envVariables.put("AWS_ACCESS_KEY_ID", System.getenv("AWS_ACCESS_KEY_ID"));
envVariables.put("AWS_SECRET_ACCESS_KEY", System.getenv("AWS_SECRET_ACCESS_KEY"));
envVariables.put("AWS_SESSION_TOKEN", System.getenv("AWS_SESSION_TOKEN"));

var collector = new GenericContainer<>(TEST_IMAGE)
.withExposedPorts(4317)
Expand All @@ -69,11 +73,6 @@ private GenericContainer<?> createAndStartCollector(String configFilePath, Strin

//Mount the log file for the file log receiver to parse
collector.withCopyFileToContainer(MountableFile.forClasspathResource(logFilePath), logFilePath );
if (LOCAL_CREDENTIALS != null && !LOCAL_CREDENTIALS.isEmpty()) {
collector.withCopyFileToContainer(MountableFile.forHostPath(LOCAL_CREDENTIALS), "/root/.aws/");
} else {
collector.withEnv(System.getenv());
}

collector.start();
collector.waitingFor(Wait.forHealthcheck());
Expand Down

0 comments on commit be4d18f

Please sign in to comment.