I'm trying to run the NewAg-ApiKey
cmdlet in aws powershell. I'm unsure on the format of the StageKeys
. Can someone clarify this?
Currently writing the New-AgApiKey
as:
New-AGApiKey -CustomerId '11' -Description 'aa' -Enabled $True -GenerateDistinctId $True -Name 'newAPIKey'-StageKeys [{"RestApiId":'yz50sp19a7'},{"StageName":'wh1'}] -Force
and getting the following errors
At C:\Users\sgoswami\Desktop\Scripts\create1.ps1:2 char:132 + ... $True -Name 'newAPIKey'-StageKeys [{"RestApiId":'yz50sp19a7'},{"Stag ... + ~~~~~~~~~~~~~ Unexpected token ':'yz50sp19a7'' in expression or statement. At C:\Users\sgoswami\Desktop\Scripts\create1.ps1:2 char:159 + ... Key'-StageKeys [{"RestApiId":'yz50sp19a7'},{"StageName":'wh1'}] -Forc ... + ~~~~~~ Unexpected token ':'wh1'' in expression or statement. + CategoryInfo : ParserError: (:) [], ParseException + FullyQualifiedErrorId : UnexpectedToken
Try creating the ApiKey without StageKeys at all. It isn't a required parameter, and per the New-AGApiKey documentation this parameter has been deprecated in favor of usage plans:
-StageKey StageKey[]
DEPRECATED FOR USAGE PLANS - Specifies stages associated with the API key.
Required? False
Position? Named
Accept pipeline input? False
This option has likewise been deprecated in the CLI and other SDKs.
If you still need to use StageKeys, the Amazon.APIGateway.Model.StageKey type is defined here, in the AWS SDK for .NET documentation. You can create a new instance of this type in powershell as described below, where a powershell with matching property names and values is used as input for the new object:
$obj = New-Object Amazon.APIGateway.Model.StageKey -Property @{ RestApiId = "myId"; StageName = "myName" }
To verify the type is correct:
$obj | get-member
TypeName: Amazon.APIGateway.Model.StageKey
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
RestApiId Property string RestApiId {get;set;}
StageName Property string StageName {get;set;}