Open gesnaud opened 2 years ago
Hi there o/
I forget to precise that i've made little enhancement on rover's scripts to be able to manage the id
resource:
[...]
-a|--action)
export tf_action=$(parameter_value --action "${2}")
shift 2
;;
-id)
export tf_id="${2}"
shift 2
[...]
function other {
echo "@calling other"
echo "running terraform ${tf_action} -state="${TF_DATA_DIR}/tfstates/${TF_VAR_level}/${TF_VAR_workspace}/${TF_VAR_tf_name}" ${tf_id}"
download_tfstate
rm -f $STDERR_FILE
terraform \
${tf_action} \
-state="${TF_DATA_DIR}/tfstates/${TF_VAR_level}/${TF_VAR_workspace}/${TF_VAR_tf_name}" \
${tf_id} 2>$STDERR_FILE | tee ${tf_output_file}
#${tf_command} 2>$STDERR_FILE | tee ${tf_output_file}
RETURN_CODE=${PIPESTATUS[0]} && echo "Terraform ${tf_action} return code: ${RETURN_CODE}"
# upload_tfstate
[...]
You could notice that I add upload_tfstate
and download_tfstate
to workaround the no state file. I comment it for now to avoid effects for other commands.
Thanks!
Here is a proposal for a clean 'patch' for tfstate_azurerm.sh.
You will notice that I have to use a 'swap' file ( /tmp/tf_pipe_code
)as I cannot get variable value from a subshell to the parent 🤔.
[...]
-a|--action)
export tf_action=$(parameter_value --action "${2}")
shift 2
;;
-id)
export tf_id="${2}"
shift 2
[...]
function other {
echo "@calling other"
rm -f $STDERR_FILE
[[ "${tf_action}" == *"rm"* ]] && \
(echo "tf_action *SHOULD* containing rm: "${tf_action};
download_tfstate)
[[ "${tf_action}" == *"state"* ]] && \
(echo "running terraform ${tf_action} -state="${TF_DATA_DIR}/tfstates/${TF_VAR_level}/${TF_VAR_workspace}/${TF_VAR_tf_name}" ${tf_id}";
terraform \
${tf_action} \
-state="${TF_DATA_DIR}/tfstates/${TF_VAR_level}/${TF_VAR_workspace}/${TF_VAR_tf_name}" \
${tf_id} \
2>$STDERR_FILE | tee ${tf_output_file};
echo ${PIPESTATUS[0]} > /tmp/tf_pipe_code);
[[ "${tf_action}" != *"state"* ]] && \
(echo "running terraform ${tf_action} -state="${TF_DATA_DIR}/tfstates/${TF_VAR_level}/${TF_VAR_workspace}/${TF_VAR_tf_name}" ${tf_command}";
terraform \
${tf_action} \
-state="${TF_DATA_DIR}/tfstates/${TF_VAR_level}/${TF_VAR_workspace}/${TF_VAR_tf_name}" \
${tf_command} \
2>$STDERR_FILE | tee ${tf_output_file};
echo ${PIPESTATUS[0]} > /tmp/tf_pipe_code);
TF_PIPE_CODE=$(cat /tmp/tf_pipe_code);
rm -f /tmp/tf_pipe_code;
RETURN_CODE=${TF_PIPE_CODE} && echo "Terraform ${tf_action} return code: ${RETURN_CODE}"
if [ -s $STDERR_FILE ]; then
if [ ${tf_output_file+x} ]; then cat $STDERR_FILE >>${tf_output_file}; fi
echo "Terraform returned errors:"
cat $STDERR_FILE
RETURN_CODE=2003
fi
if [ $RETURN_CODE != 0 ]; then
error ${LINENO} "Error running terraform ${tf_action}" $RETURN_CODE
else
[[ "${tf_action}" == *"rm"* ]] && upload_tfstate
fi
echo ""
}
@LaurentLesle I was thinking to make a pull request on the branch concerning aztfmod/rover:1.0.7-2109.2410 but I cannot find the matching info?
Where is the matrix version of github aztfmod/rover
giving dockerhub aztfmod/rover
?
Hi Jason!
In your rover command line, you specified the resources address right?
Thx, Greg
----- Mail original ----- De: "Jason Dossett" @.> À: "aztfmod/rover" @.> Cc: "Gregory ESNAUD" @.>, "Mention" @.> Envoyé: Jeudi 26 Janvier 2023 16:53:42 Objet: Re: [aztfmod/rover] rover 'state rm': state file not found (Issue #292)
@gesnaud When I try your changes above, I get "At least one address is required." It doesn't look like the address is being included in the command call: running terraform state rm -state=/home/vscode/.terraform.cache/sepazcafenv/rover_jobs/20230126154929728220187/tfstates/level3/tfstate/lz_common_subscriptions.tfstate Usage: terraform [global options] state rm [options] ADDRESS...
Did I miss something?
— Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you were mentioned. Message ID: <aztfmod/rover/issues/292/1405218660 @ github . com>
I did not but I quickly figured out that’s what I was doing wrong which is why I deleted the question. :)
Thanks for the patch, it was very helpful!
On Jan 27, 2023, at 4:48 AM, Gregory ESNAUD @.***> wrote:
Hi Jason!
In your rover command line, you specified the resources address right?
Thx, Greg
----- Mail original ----- De: "Jason Dossett" @.> À: "aztfmod/rover" @.> Cc: "Gregory ESNAUD" @.>, "Mention" @.> Envoyé: Jeudi 26 Janvier 2023 16:53:42 Objet: Re: [aztfmod/rover] rover 'state rm': state file not found (Issue #292)
@gesnaud When I try your changes above, I get "At least one address is required." It doesn't look like the address is being included in the command call: running terraform state rm -state=/home/vscode/.terraform.cache/sepazcafenv/rover_jobs/20230126154929728220187/tfstates/level3/tfstate/lz_common_subscriptions.tfstate Usage: terraform [global options] state rm [options] ADDRESS...
Did I miss something?
— Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you were mentioned. Message ID: <aztfmod/rover/issues/292/1405218660 @ github . com>
— Reply to this email directly, view it on GitHubhttps://github.com/aztfmod/rover/issues/292#issuecomment-1406264380, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AU2J37YHQC6AWCNXK76NQFTWUOKVTANCNFSM6AAAAAASKN36BE. You are receiving this because you commented.Message ID: @.***>
Great :)
Have a nice day!
----- Mail original ----- De: "Jason Dossett" @.> À: "aztfmod/rover" @.> Cc: "Gregory ESNAUD" @.>, "Mention" @.> Envoyé: Vendredi 27 Janvier 2023 11:51:54 Objet: Re: [aztfmod/rover] rover 'state rm': state file not found (Issue #292)
I did not but I quickly figured out that’s what I was doing wrong which is why I deleted the question. :)
Thanks for the patch, it was very helpful!
On Jan 27, 2023, at 4:48 AM, Gregory ESNAUD @.***> wrote:
Hi Jason!
In your rover command line, you specified the resources address right?
Thx, Greg
----- Mail original ----- De: "Jason Dossett" @.> À: "aztfmod/rover" @.> Cc: "Gregory ESNAUD" @.>, "Mention" @.> Envoyé: Jeudi 26 Janvier 2023 16:53:42 Objet: Re: [aztfmod/rover] rover 'state rm': state file not found (Issue #292)
@gesnaud When I try your changes above, I get "At least one address is required." It doesn't look like the address is being included in the command call: running terraform state rm -state=/home/vscode/.terraform.cache/sepazcafenv/rover_jobs/20230126154929728220187/tfstates/level3/tfstate/lz_common_subscriptions.tfstate Usage: terraform [global options] state rm [options] ADDRESS...
Did I miss something?
— Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you were mentioned. Message ID: <aztfmod/rover/issues/292/1405218660 @ github . com>
— Reply to this email directly, view it on GitHubhttps://github.com/aztfmod/rover/issues/292#issuecomment-1406264380, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AU2J37YHQC6AWCNXK76NQFTWUOKVTANCNFSM6AAAAAASKN36BE. You are receiving this because you commented.Message ID: @.***>
— Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you were mentioned. Message ID: <aztfmod/rover/issues/292/1406332714 @ github . com>
Hello,
I'm facing an issue when trying to make a
state rm
in rover command:And the result is a
state file was found!
error message::But a
state show
is working fine:And the result is:
My questions are:
state rm
a rover's bug?state list
orstate show
are working?state show/list
?My environment