I have been working on a script that will link together a variety of EC2 resources via their properties. For example, a VPC object normally looks like this
(Note that ResourceID and Exists are two custom properties that I add in to help reduce the amount of iterations I have to do in certain parts of the script)
However, I have not been able to find a way to do this reliably and consistently without breaking the script. After digging deep into this I think the issue may be that there are no overloaded method definitions for get/set-ing these properties' values with anything except a String.
Is your Feature Request related to a problem?
As far as I am concerned, these cmdlets are working and working really well. Without them I would not have learned as much as I did and I am extremely thankful for them. I am just looking to finish out this fun project that has gotten completely out of hand (like all projects).
Proposed Solution
I have not done any work with C# so I cannot say what would be the best course of action if there even would be one taken. I wish I had a bunch of spare time to sit down, learn C#, and make a viable solution for this. I assume it has to do with there not being an overloaded function definition but that is a wild guess.
Describe alternatives you've considered
As I have more time to work on my script I plan on working around this by making custom objects whenever I have to. Creating EC2 objects with [Amazon.EC2.Model.InstanceBlockDeviceMapping]::new() and then trying to modify them beyond what is currently supported is my issue. It gets worse when I try and add them to a generic list like New-Object 'System.Collections.Generic.List[Amazon.EC2.Model.InstanceBlockDeviceMapping]' because it is expecting a specific type of object and I am feeding it a modified version. The current best solution I have found is to exclude the properties I will be modifying with I create the object; [Amazon.EC2.Model.EbsInstanceBlockDevice]::new() | Select-Object -Property * -ExcludeProperty "VolumeId". I then use ArrayLists instead of generic lists to hold the collections of these objects.
Additional Context
I would say what I am doing is mostly for fun and less so practical. However, it would make doing audits way easier. With just 10 API calls you are able to enumerate a large majority of your EC2 infrastructure. Then this script takes that information and ties it all together for you. I have used earlier versions of this script to locate Snapshots of instances that longer exist, determine all the instances that have a certain port open, audit security groups, and more. I personally found it way easier to get information when instead of being presented with a resource ID, I am instead presented with its actually object.
We have noticed this issue has not recieved attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.
Describe the Feature
I have been working on a script that will link together a variety of EC2 resources via their properties. For example, a VPC object normally looks like this
And what I am doing in my script is taking that
DhcpOptionsId
String and turning it into aAmazon.EC2.Model.DhcpOptions
object.(Note that ResourceID and Exists are two custom properties that I add in to help reduce the amount of iterations I have to do in certain parts of the script) However, I have not been able to find a way to do this reliably and consistently without breaking the script. After digging deep into this I think the issue may be that there are no overloaded method definitions for get/set-ing these properties' values with anything except a String.
Is your Feature Request related to a problem?
As far as I am concerned, these cmdlets are working and working really well. Without them I would not have learned as much as I did and I am extremely thankful for them. I am just looking to finish out this fun project that has gotten completely out of hand (like all projects).
Proposed Solution
I have not done any work with C# so I cannot say what would be the best course of action if there even would be one taken. I wish I had a bunch of spare time to sit down, learn C#, and make a viable solution for this. I assume it has to do with there not being an overloaded function definition but that is a wild guess.
Describe alternatives you've considered
As I have more time to work on my script I plan on working around this by making custom objects whenever I have to. Creating EC2 objects with
[Amazon.EC2.Model.InstanceBlockDeviceMapping]::new()
and then trying to modify them beyond what is currently supported is my issue. It gets worse when I try and add them to a generic list likeNew-Object 'System.Collections.Generic.List[Amazon.EC2.Model.InstanceBlockDeviceMapping]'
because it is expecting a specific type of object and I am feeding it a modified version. The current best solution I have found is to exclude the properties I will be modifying with I create the object;[Amazon.EC2.Model.EbsInstanceBlockDevice]::new() | Select-Object -Property * -ExcludeProperty "VolumeId"
. I then use ArrayLists instead of generic lists to hold the collections of these objects.Additional Context
I would say what I am doing is mostly for fun and less so practical. However, it would make doing audits way easier. With just 10 API calls you are able to enumerate a large majority of your EC2 infrastructure. Then this script takes that information and ties it all together for you. I have used earlier versions of this script to locate Snapshots of instances that longer exist, determine all the instances that have a certain port open, audit security groups, and more. I personally found it way easier to get information when instead of being presented with a resource ID, I am instead presented with its actually object.
Map showing all the connections: https://i.imgur.com/bCWEhMM.png Reddit post I made about this while trying to figure out a solution: https://www.reddit.com/r/PowerShell/comments/imhkh2/addmember_not_overwriting_member_even_with_force/ The Get-AWSEC2 script in its current state should it help add context: https://github.com/picnicsecurity/Get-AWSEC2
Environment
This is a :rocket: Feature Request