aws / aws-tools-for-powershell

The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment.
Apache License 2.0
241 stars 79 forks source link

get-emrcluster should return cluster tags #66

Closed nwsparks closed 4 years ago

nwsparks commented 4 years ago

I am unable to find any way to get the tags associated with a cluster via powershell. It looks like it is possible via aws cli:

https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-plan-tags-view.html

can functionality be added to get-emrcluster to return the tags as well?

ketanbhut commented 4 years ago

Hi, The CLI is utilizing --query to select specific property to display. You should be able to do similar things with PowerShell:

Get-EMRCluster -ClusterId $clus.Id -Region us-east-1 |Select-Object -ExpandProperty tags

Key Value


ABCD EFG Name new-cluster

nwsparks commented 4 years ago

@ketanbhut That is the issue, Get-EMRCluster does not return a tag property. There is no way to retrieve the tags via any of the PS cmdlets.

get-emrclusters -ClusterState 'WAITING' | select -first 1 |GM

   TypeName: Amazon.ElasticMapReduce.Model.ClusterSummary
Name                    MemberType Definition
----                    ---------- ----------
Equals                  Method     bool Equals(System.Object obj)
GetHashCode             Method     int GetHashCode()
GetType                 Method     type GetType()
ToString                Method     string ToString()
Id                      Property   string Id {get;set;}
Name                    Property   string Name {get;set;}
NormalizedInstanceHours Property   int NormalizedInstanceHours {get;set;}
Status                  Property   Amazon.ElasticMapReduce.Model.ClusterStatus Status {get;set;}
ketanbhut commented 4 years ago

Hi, Get-EMRCluster is different from get-emrclusters

The other is alias for Get-EMRClusterList

get-alias Get-EMRClusters|fl

The return type is different for Get-EMRClusters

(Get-EMRClusters -ClusterState STARTING |select -fir 1).Gettype()

Check the return type on Get-EMRCluster:

Get-EMRClusters | foreach {(Get-EMRCluster -ClusterId $_.id).GetType()}

Check the diff in commandlet Get-EMRCluster - which expects an ID it does have tags:

Get-EMRClusters | foreach {Get-EMRCluster -ClusterId $.id |gm Tags} Get-EMRClusters | foreach {Get-EMRCluster -ClusterId $.id | select -expand tags}

nwsparks commented 4 years ago

I see it now, thanks. I'll close the ticket.