Closed vikas027 closed 4 years ago
Try export my_new_role_arn=...; yq .data.mapRoles[0].roleArn=env.my_new_role_arn
.
On Sun, May 3, 2020 at 10:57 AM Vikas Kumar notifications@github.com wrote:
I am trying to replace rolearn in the below yaml with a value, I've read the docs but could not figure out how to replace rolearn here.
apiVersion: v1kind: ConfigMapmetadata: name: aws-auth namespace: kube-systemdata: mapRoles: | - rolearn: <ARN of instance role (not instance profile)> username: system:node:{{EC2PrivateDNSName}}
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kislyuk/yq/issues/94, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGSOPN2FFVXEHBRXF44V3DRPWV7TANCNFSM4MYHDLGA .
yq .data.mapRoles[0].roleArn=env.my_new_role_arn
Thanks, @kislyuk .
I think I had tried doing the same but faced below error
~/.../eks (dev) $ export new_arn="xxxx"
~/.../eks (dev) $ yq .data.mapRoles[0].rolearn=env.new_arn aws-auth-cm.yaml
jq: error (at <stdin>:1): Cannot index string with number
~/.../eks (dev) $
Ah, that's because your mapRoles is double-serialized. Do you know if it's supposed to be that way? If it is, you can do something like export value=NEW_ARN; export inner=$(yq -r .data.mapRoles t.yml| yq .[0].rolearn=env.value); yq .data.mapRoles=env.inner t.yml
where your input file is in t.yml.
Thanks, @kislyuk That worked like a charm but it is a bit of an overkill with yq
I guess, I will stick to sed
for this use case :)
I am trying to replace
rolearn
in the below yaml with a value, I've read the docs but could not figure out how to replacerolearn
here.