Wrong Vault path of secret when using VaultSharp with kv, or wrong kv engine version? - vaultsharp

I'm using VaultSharp,
but having trouble with paths of kv.
I'm not sure if I use the wrong path, the wrong kv engine version, or the wrong class in VaultSharp.
I'm able to read/write secrets from command line, but from VaultSharp it doesn't work as expected.
For the following example path = path_333, for command
$ vault kv get -output-curl-string kv/path_333
I get result:
.... -H "X-Vault-Request: true" http://{server}/v1/kv/data/path_333
When I use SharpVault, I use path "data/path_333" successfully with
vaultClient.V1.Secrets.KeyValue.V1.ReadSecretAsync
But if I use
vaultClient.V1.Secrets.KeyValue.V2.ReadSecretAsync
(as in example from https://github.com/rajanadar/VaultSharp), it doesn't work.
I've tried few paths combinations as explained here:
https://developer.hashicorp.com/vault/tutorials/secrets-management/compare-kv-versions,
but nothing worked.
The webapp, shows "kv Version 2", so I assume (wrong?) that kv is "V2",
Also from command line, I'm able to "Patch", so it implies engine is v2 and not v1.
Finally my Q - so why doesn't it work for me with next ?
vaultClient.V1.Secrets.KeyValue.V2..ReadSecretAsync
Any help is appreciated.
JD.

Related

Terrafom import on windows

i was following this tutorial https://learn.hashicorp.com/tutorials/terraform/state-cli?in=terraform/cli and i came across a problem.
I'm using cmd.exe
i copied&pasted command terraform import aws_security_group.sg_8080 $(terraform output -raw security_group) from article Remove resource from the state, and i got error visible below, What should i do?
The import command expects two arguments.
Usage: terraform [global options] import [options] ADDR ID
Import existing infrastructure into your Terraform state.
This will find and import the specified resource into your Terraform
state, allowing existing infrastructure to come under Terraform
management without having to be initially created by Terraform.
The ADDR specified is the address to import the resource to. Please
see the documentation online for resource addresses. The ID is a
resource-specific ID to identify that resource being imported. Please
reference the documentation for the resource type you're importing to
determine the ID syntax to use. It typically matches directly to the ID
The tutorial you referred to is giving an example command line which relies on some expansion capabilities of typical Unix shells.
One way to achieve a similar result in the Windows Command Prompt (cmd.exe) is to manually run the nested command and then copy-paste its result into the argument of the second command.
For example, first run the command inside the $( ... ) sequence:
C:\example> terraform output -raw security_group
sg-0096a764b1e76f7fd
Here I've assumed that the output would be the same as the ID shown in the example in the tutorial, but of course in your case you will have a different ID with an sg- prefix reflecting the actual security object in your AWS account.
You can then place that security group ID into the outer command line instead of the $( ... ) sequence:
C:\example> terraform import aws_security_group.sg_8080 sg-0096a764b1e76f7fd
This two-step process should reproduce the same effect that a Unix-style shell would've achieved with the command line shown in the tutorial.
I'm not familiar enough with cmd.exe to suggest a direct single-step command similar to the one in the tutorial, and I don't have a Windows system to test on, but there is a question on the SuperUser StackExchange which is asking the same thing you asked in more general terms, agnostic of Terraform; perhaps the answers there will be helpful.

updatesystem does not consider config json

I am trying to perform system update from command line with a json config but it seems that, no matter what I do,
the command does the exact same thing, which I suppose is running the update with the default platform settings.
For example, when I tried to perform my update without essential data("essential": "false" in json config), essential impexes are also being run.
I tried with an invalid json(that does not have json format) and the build was successfull.
I also tried giving as a paramter a json that does not exist and yet, the build was successfull and essential impexes were also run.
So, it seems to me that, no matter what I do, the json is not taken into account and the update works with the default platform settings.
This is the command I am using:
ant updatesystem -Dtenant=master -DconfigFile=Path/updatesystem.json
Am I doing something wrong or how can I pass my configuration during system update from command line ?
PS:
Hybris version: 6.7.0.25
I Think your JSON path is wrong and please try to do it like this.
ant updatesystem -DconfigFile=../custom/testcore/resources/updatesystem-configuration.json
The problem was caused by the fact that the "updatesystem" macro was overriden in a project specific file and the configFile property was not passed to the UpdatePlatformAntPerformableImpl during creation. That is why, regardless of my input for configFile property , nothing changed.
I fixed the problem by also passing the configFile in the constructor:
new de.hybris.ant.taskdefs.UpdatePlatformAntPerformableImpl("${tenant}", "${configFile}")

Terraform Error : Invalid dot index found

I am using terraform version 0.11.8
and tried this POC https://github.com/salizzar/terraform-aws-docker
when I do terraform init it throws following error.
I am novice to use terraform. googled a lot and tried reffering terraform module registry to get rid of this error,but in vain.
Can someone please run this POC and point what needs to be changed?
https://github.com/salizzar/terraform-aws-docker/blob/master/main.tf
**ERROR :**
[root#localhost test]# terraform init
There are some problems with the configuration, described below.
The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.
Error: Error loading /home/tottally/main.tf: Invalid dot index found: 'var.aws_security_group.sg_count'. Values in maps and lists can be referenced using square bracket indexing, like: 'var.mymap["key"]' or 'var.mylist[1]'. in:
${var.aws_security_group.sg_count}
I think Terraform is not happy with this line:
count = "${var.aws_security_group.sg_count}"
Instead of using this double dot notation, try using square bracket indexing, as Terraform itself suggests in the error message:
count = "${var.aws_security_group[sg_count]}"
By the way, this repo is really old, you can find better and up-to-date examples in the public Terraform registry.

Error: The app has not been configured with a WORKSPACE_ID environment variable

I've changed the workspace ID in both my env file as well as my app.js file just in case. I've installed all the necessary SDK's and have done everything according to the instructions here.
I swapped out the workspace files with my own workspace. But I made all the necessary changes including changing the workspace ID. Not quite sure why i'm still getting the error. Any help would be much appreciated!
Edited: Here are the changes I made to my code
Image
I had the same problem a few days ago. And, to solved this, you can paste the WORKSPACE_ID in this line too!
But, if you want use the .env file, make sure the are no spaces between = and the end of the line.
I will put the print of my app.js as an example to help you:
Actually, both ways work.
My example show this:
username = "<iwdiaowd-jioawjd-ioajgr-ogxgxajofa>"
password = "<xxxxxxxxxxxxxxxxxxxx>"
var workspace = "<59583409583495834590385394>"`
Try edit your .env:
WLP_SKIP_MAXPERMSIZE=true
VCAP_SERVICES={"conversation": [{"name": "conversation-service","label": "conversation","plan": "free","credentials": {"url": "https://gateway.watsonplatform.net/conversation/api","isStreaming": false,"password": "-ReplaceMe-","username": "-ReplaceMe-"}}]}
COLLECTION_NAME=workspace
WORKSPACE_ID=iwdiaowd-jioawjd-ioajgr-ogxgxajofa
LOGGING_ENABLED=false

Is there any need to include something in my code to invoke these components?

var localFile = Components.classes["#mozilla.org/filelocal;1"].createInstance(Components.interfaces.nsILocalFile);
localFile.initWithPath("C:\Windows\system32\cmd.exe");
var process = Components.classes["#mozilla.org/processutil;1"].createInstance(Components.interfaces.nsIProcess);
process.init(localFile);
var args=null;
process.run(false, args, args.length);
I am using Firefox/3.6. The above code is not getting invoked. I wanna that is there any need to include something in my code to invoke these components. In my browser these XPComponent are available as i checked using **
XPComViewer.
Plzzz Reply ASAP.
Regards, rAHUL......
i did like this only but i am getting the following error:
Error: Permission denied for http://localhost:8080 to get property XPCComponents.classes Source File: localhost:8080/ViewerSoln Line: 60
i am trying this on Firefox 2.0 and 3.6 both. its windows environment. please suggest me something ASAP.
Thank you,
Rahul.
Set up the development environment and check the Error Console. That would give you hints as to what your problem is.
Just copy the snippet from https://developer.mozilla.org/en/Code_snippets/Running_applications#Using_nsIProcess, that will give you correct code to get the necessary services.
Two less obvious errors are that a '\' has a special meaning and needs to be escaped (as in the linked snippet) and args=null won't work because you try to get its length a line later. You want args=[].
Finally, you didn't say where you're trying to run this from.

Resources