AWS CLI commands in PowerShell like ec2, s3api work just fine, but deploy commands always throw a usage error. Why is this?
EDIT
If you've worked with the AWS CLI, you probably are aware of what commands I am
referenceing... But if you need example commands:
This works just fine in a PowerShell Script. So does aws s3api list-object, etc...
aws ec2 describe-instance-status --instance-id $ec2_instance_id.Trim() --region us-east-1 --query "InstanceStatuses[].InstanceState[].Name"
This does not work:
aws deploy create-deployment --application-name MyWebApp --s3-location bucket=sthreebucketname,bundleType=zip,eTag=abac12345jkjdafdafdf,key=MyWebApp.zip --deployment-group-name DepGroup --deployment-config-name CodeDeployDefault.OneAtATime --description "MyApp Deployment"
I have set the user environment variable to my administrator. I have also set up PowerShell with my AWS credentials when I installed the Deploy Agent. So I should have no issue with access or permissions, but evidently it doesn't like the "deploy" suite of commands.
EDIT 2
Here is the error message. I know it says usage, but the same command works on the command prompt just fine.
aws : usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
At C:\scripts\deploy-to-instance.ps1:1 char:11
+ $result = aws deploy create-deployment --application-name MyWebApp --s3-location ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (usage: aws [opt....] [parameters]:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
Unknown options: eTag=abac12345jkjdafdafdf, key=MyWebApp.zip, bundleType=zip
New-CDDeployment command from the AWSPowerShell tool does the same thing.
What other permissions need to be set then?
It is not a permissions error at all.
The answer is:
The syntax in PowerShell is different(more finicky) than what the command prompt expects. You need to have quotations and commas in the exact correct spot for it to work properly.
If you are using the --query option, make sure your query's have the EXACT syntax. It seems the command prompt cli can use a slightly different syntax without throwing errors.
Related
so i'm trying to createdb in visualstudio code with mikro-orm and postgresql but there's an error:
createdb lireddit
The name "createdb" is not recognized as the name of a cmdlet, function, script file, or executable program. Check the spelling
name, as well as the presence and correctness of the path, and then try again.
+ createdb <<<< lireddit
+ CategoryInfo : ObjectNotFound: (createdb:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Before that i installed mikro-orm and postgresql with yarn, but it doesn't seem to work.
There is no option as mentioned in mikro-orm documentation to create a db using createdb mikro-orm docs .
The video you were following which led you here has setup some scripts or aliases in his bash_profile.sh and installed PG-CLI to do this locally to createdb using terminal.
Solution to how to do it the native way:
The database wont be created by running createdb in terminal.
First install postgresql server from EDB Installer site which gives all the tools to run your postgresql server and also a client called pgAdmin to interact with your postgresql server.
Once you have installed all the requirements. Open pgAdmin and create the data-base as shown in the image below.
Incase you are having trouble ahead on how the migrations happen from your project to postgresql through mikro-orm, let me know. I can help
I'm attempting to script a backup process of a docker volume hosted in a azure linux app service.
I need to create a ssh tunnel using powershell. Calling the script from task scheduler with the following powershell -noninteractive -File R:\path\to\ftp-backups.ps1
When the following command is executed to create the tunnel
az webapp create-remote-connection --subscription 00000000-9dfs-4fdsxexxxx-324jklsdf4308320324 --resource-group my-resource-group -n my-app-name -p 12345
The powershell dialog that has come up offers the interactive options of
Opening tunnel on port: 12345
SSH is available { username: user, password: password }
Ctrl + C to close
The script does not move past this point, how can I suppress this interactive dialog prompt so the rest of the script will continue?
I responded to your question on a different forum. Posting here for visibility
The engineering team revamped this command recently which was deployed as part of CLI release 2.8.0. The PowerShell script should work now.
https://github.com/MicrosoftDocs/azure-docs-cli/blob/master/docs-ref-conceptual/release-notes-azure-cli.md#appservice-1
I have a build pipeline to deploy something to AWS via Azure Devops pipeline using the AWS CodeDeploy task. I want to report on the detail of this deployment by using the output variable of deployment Id from the AWS CodeDeploy task step as an input to query the deployment via the next task AWS CLI command.
Here is the AWS CodeDeploy step, and the configuration of the output variable.
Here is the subsequent step, using that variable.
Here is the output error from the build pipeline.
Code Deploy task:
Started deployment of new revision to deployment group VSTSEc2Targets for application VSTSTestApp, deployment ID d-PN4UXHVJO
Setting output variable deployment_id with the ID of the deployment
Waiting for deployment to complete
AWS CLI task:
[command]C:\windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\Python\3.6.8\x64\Scripts\aws.cmd deploy get-deployment --deployment-id "$(codedeploy.deployment_id)""
An error occurred (InvalidDeploymentIdException) when calling the GetDeployment operation: Specified DeploymentId is not in the valid format: $(codedeploy.deployment_id)
##[error]Error: The process 'C:\hostedtoolcache\windows\Python\3.6.8\x64\Scripts\aws.cmd' failed with exit code 255
It appears to not be converting the variable to actual value. Can anyone assist?
I tested outputting the variable via PowerShell and got this error:
variable check
codedeploy.deployment_id : The term 'codedeploy.deployment_id' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At D:\a\_temp\4985f146-ca74-46a3-aed2-aa67cdc2e01a.ps1:5 char:14
+ Write-Host $(codedeploy.deployment_id)
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (codedeploy.deployment_id:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CommandNotFoundException
##[error]PowerShell exited with code '1'.
##[section]Finishing: PowerShell Script
Using script:
# Write your PowerShell commands here.
Write-Host "variable check"
Write-Host $(codedeploy.deployment_id)
Solved this. The issue was my syntax. I assumed you needed to reference a variable using the reference name.variable $(reference.variable) when in fact you only need to use $(variable). The reference name - while required to specify in the task definition - is not used when referencing the value elsewhere. I was following the Microsoft documentation which states the following:
Use outputs in the same job
In the Output variables section, give the producing task a reference name. Then, in a downstream step, you can use the form $(ReferenceName.VariableName) to refer to output variables.
From: https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=classic%2Cbatch
I am running the following in a CLI task on Azure Devops (inline)
rem Create the Service Plan
call az appservice plan create --resource-group %RESOURCE_GROUP% --name %SERVICE_NAME% --sku B1
Whch works just fine. However, I'm having to scroll to see the whole thing and I have other commands which are even longer. So I'm trying to split it over multiple lines so I can see more clearly what is going on.
Looking at Microsoft Docs it looked like the solution was to put a backslash on the end of each line. So I tried:
I've tried:
rem Create the Service Plan
call az appservice plan create \
--resource-group %RESOURCE_GROUP% \
--name %APP_SERVICE_NAME% \
--sku B1
Which didn't work. I then read something that recommended the back-tick/back-quote at the end of each line:
rem Create the Service Plan
call az appservice plan create `
--resource-group %RESOURCE_GROUP% `
--name %APP_SERVICE_NAME% `
--sku B1
This also didn't work. Any help greatly appreciated.
Never mind. Worked it out. Turns out you need to use '^'
rem Create the Service Plan
call az appservice plan create ^
--resource-group %RESOURCE_GROUP% ^
--name %APP_SERVICE_NAME% ^
--sku B1
For me the ` character is working. I posted earlier that it wasn't but I was inadvertently using the wrong character.
(That post seems to have been deleted by a moderator though I'm not sure why - perhaps because it was more of a "me too" than an answer, but it did add that the above "^" solution doesn't work for me).
In case it was the same issue as I had, ensure the "Backtick" you use is the correct one (it's immediately to the left of "1" on my microsoft keyboard). I was trying to use a ' in the failed attempt as the CLI docs were reading made it hard to distinguish.
The character that you need to use to specify that the command is split over multiple lines, depends on the environment in where the CLI command is run.
In other words, it depends on the scriptType property of the AzureCLI#2 command.
Powershell/Powershell Core: use a backtick `
bash: use backslash \
batch: use accent circonflexe ^
from azure cloud shell, type AZ, then copy paste the az command with \ for multiple line will not work.
but there is a fix, you click on the + sign like a adding a folder sign, it will bring a full page Azure Cloud Shell window, change to Bash from the pull down (default is Poweshell), then you see prompt changed to name#Azure:~$, now you can use az commend with \ for multiple lines.
need help :
informatica is installed on windows ,
so pmcmd will not work to schedule informatica workflow,
n e patch or utility to schedule informatica workflow (on windows) through unix(pmcmd).
any other solution to schedule informatica workflow (on windows). ??
Please Google for the error you have: " no gateway connectivity is provided for domain". And to resolve the issue, add the environment variable INFA_DOMAINS_FILE.
More can be found for example on: this page
We can run pmcmd command from windows command line.In command line mode we have to give every bit of information like (domain name,integration service name,username and passwords in each command.Below is the syntax
pmcmd startworkflow -sv Myintservice -d Mydomain -u username -p password -f foldername workflowname
Please lookup the help of pmcmd command just to make sure if I have misstated anything.