24

I checked the guide, and I asked my question (How can I use Expect to automate an AWS job?), but it seems that my question still isn't good enough.

I appreciate that it might be a difficult question to answer - or that maybe someone could take exception to what I'm trying to do - but it's still something that I need. If I didn't word my question well, or if I failed to do / consider something important then I'd really like understand what it is so that I can improve not only this question, but others that I ask in the future.

19
  • 2
    A complete answer may require specialized knowledge, folks who are familiar with Bash and AWS. You may wish to place a comment on your main site question stating that it is being discussed in meta with a link to this question. Heck, I'll do that for you, and can delete the comment if you so desire. Commented Feb 14, 2022 at 14:49
  • 3
    That being said, you may wish to explain your scripts better, tell the details of what they do, tell more of the specifics of your new attempt at a solution... Commented Feb 14, 2022 at 14:50
  • 14
    You could try to reduce the amount of code in your samples. I'm not an expert, but is the code after ASSUMED_ROLE= line needed for the example? From what I see it's never reached anyway. And you could try to find out which exact line causes the error.
    – BDL
    Commented Feb 14, 2022 at 14:51
  • 8
    I am not an expert but I think you have too much code in that question. Is there any way this could be reduced to the minimal reproducible example?
    – Dharman Mod
    Commented Feb 14, 2022 at 15:13
  • 2
    This is the problem when you marry yourself to a trick but don't know how to turn that trick into a solution and then ask others to fix what you came up with and admit don't have experience with. The question would have faired so much better if it had been about the problem and not the trick you pulled off of the shelf. It's that extra layer which just overcomplicates matters.
    – Gimby
    Commented Feb 14, 2022 at 15:16
  • 22
    This feels like the XY Problem personified. The core of your issue seems to be "how do I automate login with aws-adfs?", the standard answer would be "use --authfile", not "create an expect house of cards" Commented Feb 14, 2022 at 16:14
  • the aws client has an otuion for timeout, so it is hard t image that you get an timeout atter 3 hours, and when a tomepout of 0 doiesn't work, you should contact the support
    – nbk
    Commented Feb 14, 2022 at 17:02
  • 7
    The second subsection in the guide is "Write a title that summarizes the specific problem". The too general title is not unimportant for busy close voters. Based on the title alone, an expectation is set up for a do-my-job kind of question (which it isn't at all - it is much better than most questions). Commented Feb 14, 2022 at 17:51
  • 1
    @PeterMortensen so, it is not even really a mistake made by headbanger but rather a problem of "oh I don't want to actually read the question, let's just downvote and vote for close to get easy reputation".... ("busy close voters")... I do agree with you on that point, I just wanted to make that clear b/c in my opinion there are a lot of people on stackoverflow that don't get that their mentality is putting so many people off, and making this website a hostile place for less tech-proficient people.
    – th0bse
    Commented Feb 15, 2022 at 7:54
  • 7
    @th0bse You cannot earn reputation from downvoting or close-voting questions.
    – F1Krazy
    Commented Feb 15, 2022 at 7:56
  • 7
    @th0bse Downvotes are a measurement of the usefulnes of the question, closing unuseful questions / deleting such answers is protecting even you from unuseful questions and wrong answers saving your time when you're trying to find an answer to your question. If site quality concerns are taken as "hostile", then who ever is feeling so, is at wrong place.
    – Teemu
    Commented Feb 15, 2022 at 8:33
  • 8
    @th0bse we are not better than anyone else. The data is better. At least, that's the goal. Hard to maintain when people push mountains of unresearched low quality material in, the only way to keep it up is by setting standards and heavy curation.
    – Gimby
    Commented Feb 15, 2022 at 11:13
  • 4
    @th0bse You seem to be labouring under the impression that those who invest time in curating the content via close voting are earning reputation points? It's actually one of the activities that don't garner reputation points. They would be better spending their time answering low quality, "give the code", same issues time and again style questions if that was their motivation. But it isn't, they do it because they care about the community and the quality of the content the site contains, for everyone's benefit, it's that simple.
    – user692942
    Commented Feb 16, 2022 at 16:18
  • 3
    @th0bse: I am not defending those that only skim a post for keywords - on the contrary. I am only describing the sad state of affairs. A lot of questions are unfairly closed, because the voters don't actually read and comprehend the questions. I think the mechanics of the site should be changed, but that is unlikely to happen. It will probably take another company or organisation to change. Commented Feb 16, 2022 at 19:43
  • 2
    A lot of people accuse people of being lazy, when they disagree with their opinion.
    – Kevin B
    Commented Feb 16, 2022 at 19:46

1 Answer 1

44

How you might improve the question is a bit of an opinionated question. I can't speak for why people downvoted the question of course. But here's the issues I can see in this question. This is perhaps more detailed than necessary, and I will not argue you need to fix all of these to prevent downvotes, I'm just trying to answer the question "how could this question be better" to what I see with this question. And please don't take this the wrong way, I'm absolutely not trying to belittle your question, just trying to answer what I see as someone that's been around the AWS block a few hundred times.

First off, one issue I have is reading a history of how you got to this solution. It's generally not interesting. It feels to me like searching for a recipe, and getting a story about the author's family the first time they tried the recipe before I see the recipe. Maybe some people like the extra background, but on a site like Stack Overflow, it muddies the water. On Stack Overflow, I want to see questions, and details on what's not working, not much more.

Then there's the code:

merge of two blobs of code

You have two large code blocks that are mostly the same. To my mind, showing a history of the code as it evolved doesn't help. It's never a good sign when I need to open a diff tool to understand what's going on in a question. To the contrary, all of this code makes it harder to understand what the question's about. If you do need to point out the added bit in a block of code, a comment like # This is the bit I added that broke foo is enough. Viewing code history is useful if I'm trying to understand why a line was added, not helpful in understanding what it's doing.

And on that code, there's a lot going on here that has nothing to do with the question. You don't actually tell us where the code is failing. I can infer it from context clues, but questions fare much better if we know exactly where the code is failing.

This shows the second major issue: One of the comments you'll see added to posts a lot is "Please post a minimal reproducible example". This is for two big reasons: It helps anyone trying to answer your question, and more importantly, it helps the question asker! Often the effort of creating a small example to reproduce an example will lead to the discovery of the issue itself. It's a useful debugging technique on its own.

I'd expect this question to be a fairly simple subset of the script that calls aws-adfs using expect, and perhaps one line to verify the call worked correctly. Anything else just ends up confusing possible helpers. This is, of course, a bit of an art form. If you had just posted an expect script without clues as to what it's calling, it might not be enough to help you, but at the same time, the code you have below the call to aws sts assume-role doesn't add anything.

And, on top of all of this, expect has a fairly rich debug mode. What does that show? I expect (no pun intended) question answers to use debuggers available to them first, and expect is no different. I very much expect (ok, that one was deliberate) that if you had run your script with expect -d, you would have seen the core issue here, or at least had something to add to the question that would have no doubt been obvious to anyone familiar with expect.

Finally, on a technical side, there are a few things that sour me in this post:

  • As mentioned in a comment, aws-adfs has a supported way to pass credentials in. You're not using them, but unless you tell me why, perhaps unfairly, I'm going to assume the reason is you didn't know about it, which makes me question how much research you did. Not fair, at all, I admit, but it leaves a bad taste.
  • Speaking of, manually breaking out the credentials using assume-role like this is odd, to say the least, when AWS cli has a supported way to assume a role without needing to pass around secrets manually.
  • The assumption later on that all prefixes in your bucket are 32 characters out in each listing might be fine for your use case, but it's not safe in the general case. It's probably better to use s3api list-objects and jq to parse the return.

Other than the bit about passing in credentials to aws-adfs, these issues aren't helpful for your question. They just leave a bad taste in my mouth, and I'm less likely to answer questions with piles of messy code, since for better or worse, I've found it leads to a rabbit hole of follow up questions.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .