-
-
Notifications
You must be signed in to change notification settings - Fork 9
Import-Vaporshell causes ConvertFrom-Json to Fail on PS4.0 #15
Comments
I'm glad you dig! From the error, it looks like the template JSON is malformed?
It looks like it's hanging on step one there. Try this and see if you get a similar error:
If you're getting the same thing, check out the template you're importing from to ensure is correctly formatted and not missing something like a closing brace or colon |
Thx. |
Weird! Checking this out now! |
I see this reference, but I'm not that conversant in PS. |
If I wrap that JSON example in single quotes and pipe it directly to ConvertFrom-Json, it works fine for me.
What version of Powershell are you using? Easiest would be to paste the output of |
Name Value PSVersion 4.0 |
As you did, direct in quotes works for me too. |
Alright... Can you try using the full path instead of `.\awstemplate.json'? Checking if it's not resolving the path correctly |
I tried already, but will again. |
Tried, |
would you be able to attach that template.json here so I can check it out? if it contains anything sensitive, don't stress on it. There's something odd about the json itself though if it's not even working when piped into ConvertFrom-Json |
So you know, the template is a bit more complicated, but does validate, and is accepted in quotes on the command line. Hence the different name. |
Renamed with .txt, as couldn't post otherwise. |
Weird! it's working fine for me importing straight off that file:
|
didn't see anything wrong with the file either when I checked it out in VSCode, not linting issues, etc... I'd suspect something local to that computer, interested in hearing about success / etc on your other one! |
Well thanks a lot for checking. If you think of anything let me know. I've been limping this laptop along for a while. Time to move on... |
last attempt: can you try getting rid of the pipeline and seeing if the following works for you on that PC?
|
Yes. that works. |
Cool! Alright, I should have version 2.0 released by this weekend. I'll swap the way that Import-Vaporshell is using ConvertFrom-Json to that. It looks like pipeline issues with how I built the function. For the record, I was testing in PS5.1 and 6.0.0-beta5, I did not have a PS4 machine to test on at the moment. I appreciate submitting this! I'm going to keep it open as a bug and close it out once the new version is released. Cheers! |
Awsome. Glad to help. I look forward to v2. Have a great day! |
Cheers, you too! |
Nate, Import-Vaporshell works on my new Win10 laptop. Unfortunately having some other config issue. Fails on both validatingtemplate, and awscli didn't seem to install correctly. Not sure if powershellget is an issue. Need to setup the pc a bit. Will let you know if it is an issue. Prob. be a few days. I'll add that I jumped over to the new laptop because of can't use/do transform error on the old one. Probably an old version of awscli or something. |
What version of Vaporshell are you using on your Win10 laptop? The latest
version (1.2.3) actually is leveraging the AWS SDK for template validation,
not the AWS CLI.
I would love to see the error you are getting when trying
to validate template as well!
|
ok. seems likely I installed cli instead of sdk. should have time this morning to check, the vaporshell was latest, afaik. |
The SDK is actually bundled with the module now (v.1.2.3), so you shouldn't need to install anything extra =]... Send me the error you're getting if you can! |
ok. that makes more sense to me. I was just installing node etc. (I needed to anyways). I believe I have just had to re-install cfn-flip, so I'm not sure if my install permissions are allowing the install to be done correctly. Anyways, after getting rid of a cfn-flip error, I am back to the following: (Sorry I am not properly setup on the laptop, so this is just summarizing the error) I get,
|
New-CFNStack error is of course mine, as I am running from a ps1 script |
The Writes3 appears to be from my script too. I have just installed AWSPowershell, but the setup is still not quite correct |
I dunno, my credentials are not persisting properly on Win10. |
ah, I get ya! looks like you need to add your region to your credentials file. You can set/update it with
|
OK. I'll look at that. I did manage to eliminate error 3 by using Set-DefaultAWSRegion. I'll add that the command was different in earlier versions, I think. |
Ran Set-VSCredentials, which seems to have fixed Vaporshell, as it now gets right through to the validation. I still have my local PS errors. Doesn't find Write-S3Object for example, but can from command line. I'll figure it out. Error 3 has changed to the same error I was getting on teh old laptop, New-CFNStack : Create Stack cannot be used with templates containg transforms" |
For sure! The updates coming in v2 outside of small fixes are all AWS SDK wrappers, which the AWSPowerShell module already does; i.e. the following would work the same:
The main difference between AWSPowershell and Vaporshell is that you can also specify the For Serverless (or any template with Transforms), I believe you would need to create a Change Set, review, then execute it instead of deploying the stack straight away since it has to process the Transforms first: https://github.com/awslabs/serverless-application-model/blob/master/HOWTO.md#deploying-to-aws-cloudformation |
Ok. Thanks for the great explanation. I believe I even understand most of it. |
hmmm, I thought you just asked me to send you the error. Can do, if you still want it? Disregard, Github is acting weird on me. |
I changed my deployment from New-CFNStack type to "aws cloudformation deploy --template-file 'https://tcam-vapo-fn.s3.amazonaws.com/template.yaml' --stack-name 'CFNtcamUtilities' --capabilities CAPABILITY_IAM" |
Awesome! With Vaporshell 2.0, you'd be able to do something similar to the following to create the change set then execute it:
|
cool. I'm just trying to knock off some super simple lambda functions and iot rules, and this should help me do that. I hope you have a lot of success with this. |
Thank you!! Definitely a passion project right now, hopefully it becomes something essential to a lot of CFN gurus 🥇 |
@RegEM -- Just noticed something odd about calling the SDK from Powershell 3/4 that doesn't happen in 5 that is likely causing your
I've fixed it already in the new version and should hopefully have that out by this weekend! |
thanks. |
Gotcha! Well, it was at least something I encountered when testing in both PS v3 and v4 on a Win7 VM, so I felt it worth the mention. Regardless, I'm glad it was working fine for you and it'll be patched to work universally ASAP! |
Thanks Nate. |
v2.0.0 out now! https://www.powershellgallery.com/packages/Vaporshell/2.0.0 |
Hi great project.
I am stuck though running Import-Vaporshell though. I get this error, and don't know how to fix it.
Running this: $template = Import-Vaporshell .\awstemplate.json
Tried full path and in quotes etc, but haven't figured out the secret.
Please help me.
"ConvertFrom-Json : Invalid object passed in, ':' or '}' expected. (1): {
At line:36 char:24
The text was updated successfully, but these errors were encountered: