Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS SDK v2 migration #2339

Merged
merged 38 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d7fc060
V2 migration secrets (#2051)
aimethed Jul 22, 2024
6d25424
V2 migration glue (#2052)
aimethed Jul 22, 2024
bc12e0b
V2 migration jmes (#2053)
aimethed Jul 22, 2024
09ea549
v2 migration sts (#2054)
aimethed Jul 22, 2024
40a3a3f
V2 migration athena (#2055)
aimethed Jul 22, 2024
3f2a330
V2 migration KMS (#2107)
aimethed Jul 22, 2024
a60ed61
V2 migration lambda (#2077)
aimethed Jul 24, 2024
2545c7e
V2 migration s3 (#2108)
aimethed Jul 25, 2024
5d3d6f1
merge in master, to be tested
aimethed Aug 22, 2024
ec12d57
fixed SpillLocationVerifier merge errors
aimethed Aug 22, 2024
cfd6f21
Fix return statement in getGlueSchemaType method (#2199)
Jithendar12 Aug 23, 2024
e978122
v2 migration vertica issue fix (#2147)
VenkatasivareddyTR Aug 23, 2024
8277628
update v2-master with msk dependency change (#2208)
ejeffrli Aug 23, 2024
aa13dca
Update v2-master with master
ejeffrli Aug 26, 2024
c3968c5
Migrate Cloudwatch Metrics connector to v2 (#2182)
aimethed Aug 30, 2024
39551b4
V2 merge jsii (#2240)
aimethed Sep 5, 2024
f1e066d
V2 image deployment (#2253)
aimethed Sep 10, 2024
ef3602c
Migrate Elasticache to AWS SDK v2 (#2238)
Jithendar12 Sep 10, 2024
b7dd988
v2 migration elasticsearch (#2243)
VenkatasivareddyTR Sep 10, 2024
12fede5
V2 master merge 9/10 (#2255)
aimethed Sep 10, 2024
a6fc14d
update new uses of semantic version (#2258)
aimethed Sep 12, 2024
b70cbd5
v2 changes for timestream (#2239)
Trianz-Akshay Sep 13, 2024
e03a108
update all ImageURI to use correct repo name (no prod)
aimethed Sep 23, 2024
ee7804d
v2 sdk changes emr (#2288)
Trianz-Akshay Sep 24, 2024
1e7cd1f
v2 sdk changes redshift (#2289)
Trianz-Akshay Sep 24, 2024
1e685f4
migrate awslogs to cloudwatchlogs (v1 to v2) (#2272)
aimethed Sep 25, 2024
ff290f0
v2 Cloudformation (#2281)
aimethed Sep 25, 2024
945ce6a
v2 DocDB (#2282)
aimethed Sep 25, 2024
057956a
V2 rds (#2273)
aimethed Sep 25, 2024
1cea184
Merge branch 'v2-master'
aimethed Sep 25, 2024
0ab6fa3
fix missed error from merge
aimethed Sep 25, 2024
ce69cec
SDK V2 ec2 changes (#2293)
Trianz-Akshay Sep 26, 2024
a843fcd
Fix teradata (#2294)
aimethed Sep 26, 2024
ee408a2
V2 final changes (#2297)
aimethed Sep 27, 2024
d42e759
reverting PR #2273 for gbq connector as it's not required for cdk. (#…
VenkatasivareddyTR Oct 4, 2024
6532849
Merge branch 'v2-master'
aimethed Oct 16, 2024
12644d0
Update DDB new errors to v2
aimethed Oct 16, 2024
6a72c3f
Merge branch 'master' into v2-master
aimethed Oct 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 9 additions & 0 deletions athena-aws-cmdb/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM public.ecr.aws/lambda/java:11

# Copy function code and runtime dependencies from Maven layout
COPY target/athena-aws-cmdb-2022.47.1.jar ${LAMBDA_TASK_ROOT}
# Unpack the jar
RUN jar xf athena-aws-cmdb-2022.47.1.jar

# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "com.amazonaws.athena.connectors.aws.cmdb.AwsCmdbCompositeHandler" ]
5 changes: 2 additions & 3 deletions athena-aws-cmdb/athena-aws-cmdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ Resources:
spill_bucket: !Ref SpillBucket
spill_prefix: !Ref SpillPrefix
FunctionName: !Ref AthenaCatalogName
Handler: "com.amazonaws.athena.connectors.aws.cmdb.AwsCmdbCompositeHandler"
CodeUri: "./target/athena-aws-cmdb-2022.47.1.jar"
PackageType: "Image"
ImageUri: !Sub '292517598671.dkr.ecr.${AWS::Region}.amazonaws.com/athena-federation-repository-aws-cmdb:2022.47.1'
Description: "Enables Amazon Athena to communicate with various AWS Services, making your resource inventories accessible via SQL."
Runtime: java11
Timeout: !Ref LambdaTimeout
MemorySize: !Ref LambdaMemory
PermissionsBoundary: !If [ HasPermissionsBoundary, !Ref PermissionsBoundaryARN, !Ref "AWS::NoValue" ]
Expand Down
24 changes: 15 additions & 9 deletions athena-aws-cmdb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
<classifier>withdep</classifier>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-ec2</artifactId>
<version>${aws-sdk.version}</version>
<groupId>software.amazon.awssdk</groupId>
<artifactId>ec2</artifactId>
<version>${aws-sdk-v2.version}</version>
<exclusions>
<!-- replaced with jcl-over-slf4j -->
<exclusion>
Expand All @@ -28,14 +28,20 @@
</exclusions>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-emr</artifactId>
<version>${aws-sdk.version}</version>
<groupId>software.amazon.awssdk</groupId>
<artifactId>emr</artifactId>
<version>${aws-sdk-v2.version}</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-rds</artifactId>
<version>${aws-sdk.version}</version>
<groupId>software.amazon.awssdk</groupId>
<artifactId>rds</artifactId>
<version>${aws-sdk-v2.version}</version>
<exclusions>
<exclusion>
<groupId>software.amazon.awssdk</groupId>
<artifactId>netty-nio-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
import com.amazonaws.athena.connector.lambda.security.EncryptionKey;
import com.amazonaws.athena.connector.lambda.security.EncryptionKeyFactory;
import com.amazonaws.athena.connectors.aws.cmdb.tables.TableProvider;
import com.amazonaws.services.athena.AmazonAthena;
import com.amazonaws.services.secretsmanager.AWSSecretsManager;
import org.apache.arrow.util.VisibleForTesting;
import software.amazon.awssdk.services.athena.AthenaClient;
import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -77,8 +77,8 @@ public AwsCmdbMetadataHandler(java.util.Map<String, String> configOptions)
protected AwsCmdbMetadataHandler(
TableProviderFactory tableProviderFactory,
EncryptionKeyFactory keyFactory,
AWSSecretsManager secretsManager,
AmazonAthena athena,
SecretsManagerClient secretsManager,
AthenaClient athena,
String spillBucket,
String spillPrefix,
java.util.Map<String, String> configOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
import com.amazonaws.athena.connector.lambda.handlers.RecordHandler;
import com.amazonaws.athena.connector.lambda.records.ReadRecordsRequest;
import com.amazonaws.athena.connectors.aws.cmdb.tables.TableProvider;
import com.amazonaws.services.athena.AmazonAthena;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.secretsmanager.AWSSecretsManager;
import org.apache.arrow.util.VisibleForTesting;
import software.amazon.awssdk.services.athena.AthenaClient;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient;

import java.util.Map;

Expand Down Expand Up @@ -56,7 +56,7 @@ public AwsCmdbRecordHandler(java.util.Map<String, String> configOptions)
}

@VisibleForTesting
protected AwsCmdbRecordHandler(AmazonS3 amazonS3, AWSSecretsManager secretsManager, AmazonAthena athena, TableProviderFactory tableProviderFactory, java.util.Map<String, String> configOptions)
protected AwsCmdbRecordHandler(S3Client amazonS3, SecretsManagerClient secretsManager, AthenaClient athena, TableProviderFactory tableProviderFactory, java.util.Map<String, String> configOptions)
{
super(amazonS3, secretsManager, athena, SOURCE_TYPE, configOptions);
tableProviders = tableProviderFactory.getTableProviders();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,11 @@
import com.amazonaws.athena.connectors.aws.cmdb.tables.ec2.VpcTableProvider;
import com.amazonaws.athena.connectors.aws.cmdb.tables.s3.S3BucketsTableProvider;
import com.amazonaws.athena.connectors.aws.cmdb.tables.s3.S3ObjectsTableProvider;
import com.amazonaws.services.ec2.AmazonEC2;
import com.amazonaws.services.ec2.AmazonEC2ClientBuilder;
import com.amazonaws.services.elasticmapreduce.AmazonElasticMapReduce;
import com.amazonaws.services.elasticmapreduce.AmazonElasticMapReduceClientBuilder;
import com.amazonaws.services.rds.AmazonRDS;
import com.amazonaws.services.rds.AmazonRDSClientBuilder;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import org.apache.arrow.util.VisibleForTesting;
import software.amazon.awssdk.services.ec2.Ec2Client;
import software.amazon.awssdk.services.emr.EmrClient;
import software.amazon.awssdk.services.rds.RdsClient;
import software.amazon.awssdk.services.s3.S3Client;

import java.util.ArrayList;
import java.util.HashMap;
Expand All @@ -59,15 +55,15 @@ public class TableProviderFactory
public TableProviderFactory(java.util.Map<String, String> configOptions)
{
this(
AmazonEC2ClientBuilder.standard().build(),
AmazonElasticMapReduceClientBuilder.standard().build(),
AmazonRDSClientBuilder.standard().build(),
AmazonS3ClientBuilder.standard().build(),
Ec2Client.create(),
EmrClient.create(),
RdsClient.create(),
S3Client.create(),
configOptions);
}

@VisibleForTesting
protected TableProviderFactory(AmazonEC2 ec2, AmazonElasticMapReduce emr, AmazonRDS rds, AmazonS3 amazonS3, java.util.Map<String, String> configOptions)
protected TableProviderFactory(Ec2Client ec2, EmrClient emr, RdsClient rds, S3Client amazonS3, java.util.Map<String, String> configOptions)
{
addProvider(new Ec2TableProvider(ec2));
addProvider(new EbsTableProvider(ec2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
import com.amazonaws.athena.connector.lambda.metadata.GetTableRequest;
import com.amazonaws.athena.connector.lambda.metadata.GetTableResponse;
import com.amazonaws.athena.connector.lambda.records.ReadRecordsRequest;
import com.amazonaws.services.elasticmapreduce.AmazonElasticMapReduce;
import com.amazonaws.services.elasticmapreduce.model.Cluster;
import com.amazonaws.services.elasticmapreduce.model.ClusterSummary;
import com.amazonaws.services.elasticmapreduce.model.DescribeClusterRequest;
import com.amazonaws.services.elasticmapreduce.model.DescribeClusterResult;
import com.amazonaws.services.elasticmapreduce.model.ListClustersRequest;
import com.amazonaws.services.elasticmapreduce.model.ListClustersResult;
import org.apache.arrow.vector.types.Types;
import org.apache.arrow.vector.types.pojo.Schema;
import software.amazon.awssdk.services.emr.EmrClient;
import software.amazon.awssdk.services.emr.model.Cluster;
import software.amazon.awssdk.services.emr.model.ClusterSummary;
import software.amazon.awssdk.services.emr.model.DescribeClusterRequest;
import software.amazon.awssdk.services.emr.model.DescribeClusterResponse;
import software.amazon.awssdk.services.emr.model.ListClustersRequest;
import software.amazon.awssdk.services.emr.model.ListClustersResponse;

import java.util.List;
import java.util.stream.Collectors;
Expand All @@ -49,9 +49,9 @@ public class EmrClusterTableProvider
implements TableProvider
{
private static final Schema SCHEMA;
private AmazonElasticMapReduce emr;
private EmrClient emr;

public EmrClusterTableProvider(AmazonElasticMapReduce emr)
public EmrClusterTableProvider(EmrClient emr)
{
this.emr = emr;
}
Expand Down Expand Up @@ -93,23 +93,23 @@ public GetTableResponse getTable(BlockAllocator blockAllocator, GetTableRequest
public void readWithConstraint(BlockSpiller spiller, ReadRecordsRequest recordsRequest, QueryStatusChecker queryStatusChecker)
{
boolean done = false;
ListClustersRequest request = new ListClustersRequest();
ListClustersRequest request = ListClustersRequest.builder().build();

while (!done) {
ListClustersResult response = emr.listClusters(request);
ListClustersResponse response = emr.listClusters(request);

for (ClusterSummary next : response.getClusters()) {
for (ClusterSummary next : response.clusters()) {
Cluster cluster = null;
if (!next.getStatus().getState().toLowerCase().contains("terminated")) {
DescribeClusterResult clusterResponse = emr.describeCluster(new DescribeClusterRequest().withClusterId(next.getId()));
cluster = clusterResponse.getCluster();
if (!next.status().stateAsString().toLowerCase().contains("terminated")) {
DescribeClusterResponse clusterResponse = emr.describeCluster(DescribeClusterRequest.builder().clusterId(next.id()).build());
cluster = clusterResponse.cluster();
}
clusterToRow(next, cluster, spiller);
}

request.setMarker(response.getMarker());
request = request.toBuilder().marker(response.marker()).build();

if (response.getMarker() == null || !queryStatusChecker.isQueryRunning()) {
if (response.marker() == null || !queryStatusChecker.isQueryRunning()) {
done = true;
}
}
Expand All @@ -131,31 +131,31 @@ private void clusterToRow(ClusterSummary clusterSummary,
spiller.writeRows((Block block, int row) -> {
boolean matched = true;

matched &= block.offerValue("id", row, clusterSummary.getId());
matched &= block.offerValue("name", row, clusterSummary.getName());
matched &= block.offerValue("instance_hours", row, clusterSummary.getNormalizedInstanceHours());
matched &= block.offerValue("state", row, clusterSummary.getStatus().getState());
matched &= block.offerValue("state_code", row, clusterSummary.getStatus().getStateChangeReason().getCode());
matched &= block.offerValue("state_msg", row, clusterSummary.getStatus().getStateChangeReason().getMessage());
matched &= block.offerValue("id", row, clusterSummary.id());
matched &= block.offerValue("name", row, clusterSummary.name());
matched &= block.offerValue("instance_hours", row, clusterSummary.normalizedInstanceHours());
matched &= block.offerValue("state", row, clusterSummary.status().stateAsString());
matched &= block.offerValue("state_code", row, clusterSummary.status().stateChangeReason().codeAsString());
matched &= block.offerValue("state_msg", row, clusterSummary.status().stateChangeReason().message());

if (cluster != null) {
matched &= block.offerValue("autoscaling_role", row, cluster.getAutoScalingRole());
matched &= block.offerValue("custom_ami", row, cluster.getCustomAmiId());
matched &= block.offerValue("instance_collection_type", row, cluster.getInstanceCollectionType());
matched &= block.offerValue("log_uri", row, cluster.getLogUri());
matched &= block.offerValue("master_public_dns", row, cluster.getMasterPublicDnsName());
matched &= block.offerValue("release_label", row, cluster.getReleaseLabel());
matched &= block.offerValue("running_ami", row, cluster.getRunningAmiVersion());
matched &= block.offerValue("scale_down_behavior", row, cluster.getScaleDownBehavior());
matched &= block.offerValue("service_role", row, cluster.getServiceRole());
matched &= block.offerValue("service_role", row, cluster.getServiceRole());

List<String> applications = cluster.getApplications().stream()
.map(next -> next.getName() + ":" + next.getVersion()).collect(Collectors.toList());
matched &= block.offerValue("autoscaling_role", row, cluster.autoScalingRole());
matched &= block.offerValue("custom_ami", row, cluster.customAmiId());
matched &= block.offerValue("instance_collection_type", row, cluster.instanceCollectionTypeAsString());
matched &= block.offerValue("log_uri", row, cluster.logUri());
matched &= block.offerValue("master_public_dns", row, cluster.masterPublicDnsName());
matched &= block.offerValue("release_label", row, cluster.releaseLabel());
matched &= block.offerValue("running_ami", row, cluster.runningAmiVersion());
matched &= block.offerValue("scale_down_behavior", row, cluster.scaleDownBehaviorAsString());
matched &= block.offerValue("service_role", row, cluster.serviceRole());
matched &= block.offerValue("service_role", row, cluster.serviceRole());

List<String> applications = cluster.applications().stream()
.map(next -> next.name() + ":" + next.version()).collect(Collectors.toList());
matched &= block.offerComplexValue("applications", row, FieldResolver.DEFAULT, applications);

List<String> tags = cluster.getTags().stream()
.map(next -> next.getKey() + ":" + next.getValue()).collect(Collectors.toList());
List<String> tags = cluster.tags().stream()
.map(next -> next.key() + ":" + next.value()).collect(Collectors.toList());
matched &= block.offerComplexValue("tags", row, FieldResolver.DEFAULT, tags);
}

Expand Down
Loading