Skip to content

Instantly share code, notes, and snippets.

@mujahidk
Last active March 18, 2020 18:32
Show Gist options
  • Save mujahidk/df026478c4a8c00b2e9f763004dd5433 to your computer and use it in GitHub Desktop.
Save mujahidk/df026478c4a8c00b2e9f763004dd5433 to your computer and use it in GitHub Desktop.
AWS SDK - List CodeDeploy applications
@Grapes(
[
@Grab(group='software.amazon.awssdk', module='bom', version='2.10.86', type='pom'),
@Grab(group='software.amazon.awssdk', module='codedeploy', version='2.10.86'),
@Grab(group='ch.qos.logback', module='logback-classic', version='1.2.3')
]
)
import software.amazon.awssdk.services.codedeploy.*
import software.amazon.awssdk.regions.*
import software.amazon.awssdk.auth.credentials.*
import software.amazon.awssdk.services.codedeploy.model.*
def credentials = AwsBasicCredentials.create('aws-client-id', 'aws-client-secret')
def provider = StaticCredentialsProvider.create(credentials)
def client = CodeDeployClient.builder()
.region(Region.US_EAST_1)
.credentialsProvider(provider)
.build()
ListApplicationsRequest request = ListApplicationsRequest.builder()
.nextToken(null)
.build();
// NOTE: Lists only first page. Use loop and token to fetch next pages.
client.listApplications(request).applications().each {
println it
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment