-
Notifications
You must be signed in to change notification settings - Fork 727
Add opensearch packages vpc endpoint support #1078
Add opensearch packages vpc endpoint support #1078
Conversation
Adding support for opensearch packages.
Confirmed working cleanup of os packages.
Removing unused var from packages.
Correctly retrieving VPC endpoint ids.
Setting property values.
Adding id to properties.
vpcEndpointIds, err := getOpenSearchVpcEndpointIds(svc) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
listResp, err := svc.DescribeVpcEndpoints(&opensearchservice.DescribeVpcEndpointsInput{ | ||
VpcEndpointIds: vpcEndpointIds, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
resources := make([]Resource, 0) | ||
|
||
for _, vpcEndpoint := range listResp.VpcEndpoints { | ||
resources = append(resources, &OSVPCEndpoint{ | ||
svc: svc, | ||
vpcEndpointId: vpcEndpoint.VpcEndpointId, | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution!
If we have the IDs already, why are we describing them again? To make sure they exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@der-eismann apologies. You are correct. That should have been removed and is now updated.
Removing unneeded describe call.
listResp, err := svc.DescribePackages(&opensearchservice.DescribePackagesInput{}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
resources := make([]Resource, 0) | ||
|
||
for _, pkg := range listResp.PackageDetailsList { | ||
resources = append(resources, &OSPackage{ | ||
svc: svc, | ||
packageID: pkg.PackageID, | ||
packageName: pkg.PackageName, | ||
createdTime: pkg.CreatedAt, | ||
}) | ||
} | ||
|
||
return resources, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, another thing I just noticed - both resources need paging as well, just like you did in #1044. Could you do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@der-eismann No worries, updated with pagination and noted for my next PR's!
func ListOSVPCEndpoints(sess *session.Session) ([]Resource, error) { | ||
svc := opensearchservice.New(sess) | ||
|
||
vpcEndpointIds, err := getOpenSearchVpcEndpointIds(svc) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
resources := make([]Resource, 0) | ||
|
||
for _, vpcEndpointId := range vpcEndpointIds { | ||
resources = append(resources, &OSVPCEndpoint{ | ||
svc: svc, | ||
vpcEndpointId: vpcEndpointId, | ||
}) | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
func getOpenSearchVpcEndpointIds(svc *opensearchservice.OpenSearchService) ([]*string, error) { | ||
vpcEndpointIds := make([]*string, 0) | ||
|
||
listResp, err := svc.ListVpcEndpoints(&opensearchservice.ListVpcEndpointsInput{}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, vpcEndpoint := range listResp.VpcEndpointSummaryList { | ||
vpcEndpointIds = append(vpcEndpointIds, vpcEndpoint.VpcEndpointId) | ||
} | ||
|
||
return vpcEndpointIds, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't really get why you need that extra func with an extra loop in it. I think it makes more sense to do it just like you did for the OS Packages. Just list the endpoints and add them directly to the []Resource
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@der-eismann I have cleaned this up to match the OS Packages update.
Removed extra function for getting id's, incorporated into list function.
Hi @swhite-oreilly, we are suddenly seeing errors in the form of:
We are not working with OpenSearch von AWS, so I'm not really sure what changed for the error to occur. Do we need to filter these packages? |
@der-eismann, we are experiencing this as well on our end. It appears AWS added some default packages and they can't be deleted. I think filtering will need to be added. |
@der-eismann I just noticed a new one called |
I'm unsure if that filter should be name based, because then it will break again and again if they add new ones. On the other hand I see no way to differentiate AWS-provided packages from your own. |
@der-eismann open to suggestions/recommendations. I am hoping there is a limit to how many packages AWS adds for all users. |
@der-eismann one of my team members noticed that the ID's for all the internal packages start with G while user created packages appear to start with F. We have a support ticket in with AWS to verify. If that is the case, I will update the filter and test before submitting a PR. |
@der-eismann I have a PR up to fix this issue. |
This PR includes two new modules for Opensearch Packages and VPC Endpoints.
Testing
Opensearch packages and VPC endpoints were created. using the setup code mentioned below, and then AWS Nuke was used to clean these resources up, specifying
OSPackage
andOSVPCEndpoint
.us-east-1 - OSVPCEndpoint - aos-a50c4cac2357 - [VpcEndpointId: "aos-a50c4cac2357"] - would remove
us-east-1 - OSDomain - test-domain - [LastUpdatedTime: "2023-08-24T13:45:54Z"] - would remove
Scan complete: 2 total, 2 nukeable, 0 filtered.
Setup code