aws

http://status.aws.amazon.com/ https://www.expeditedssl.com/aws-in-plain-english
zackteo 2020-11-19T05:32:55.086700Z

I understand one usually types their bash script in User data but I can't seem to find a Clojure library that allows me to do this? Not sure if this is how to do automate the spinning up of a EC2 cluster

zackteo 2020-11-19T05:44:33.087500Z

Am not allowed to use managed services such as EMR, RDS, Kubernetes (it is a school project)

zackteo 2020-11-19T06:00:29.088600Z

I understand this exists https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html but automatically do this instead of having to go through the process via a website?

valtteri 2020-11-19T06:44:47.089800Z

@zackteo did you check this recipe from Spark docs already? https://spark.apache.org/docs/1.6.2/ec2-scripts.html

zackteo 2020-11-19T07:05:24.090600Z

@valtteri I actually don't understand how this works. Is this a preconfigured OS image?

zackteo 2020-11-19T07:06:28.091300Z

ohhh I'm not sure if i can expect spark to be locally installed - if this is what it requires

valtteri 2020-11-19T07:19:10.091400Z

It's a script that you run locally with your AWS credentials and it will spin up the EC2 cluster for you.

zackteo 2020-11-19T07:19:51.092200Z

Where is this Spark’s ec2 directory suppose to be located

valtteri 2020-11-19T07:20:22.092500Z

Probably inside the Spark distribution

valtteri 2020-11-19T07:21:37.093200Z

I've never used it myself but I'd guess that does all the steps you need to achieve. πŸ™‚

zackteo 2020-11-19T07:23:21.094700Z

Thanks @valtteri πŸ™‚ Let me look into it - I'm not sure if I am allowed to do it this way

valtteri 2020-11-19T07:24:42.096100Z

Ahh, if the goal is to learn how to set it up from scratch manually then that might be too automated. πŸ˜„ However, you can check clues from the script what kind of things are involved and try to reproduce them using Amazonica or whatever

valtteri 2020-11-19T07:25:27.097Z

I guess there are many steps involved (firing up the instances, installing the libs, setting up networking, security groups, autoscaling etc..)

zackteo 2020-11-19T07:35:35.098400Z

I guess my issue is that I understand how I might want to use Amazonica to initialise the instance. But how do I access that instance in an automated way to run script to just install dependencies etc

valtteri 2020-11-19T07:41:08.099700Z

Yeah, Amazonica just delegates stuff to the AWS Java SDK afaik.. So you need to check how that's done on Java side and then figure out how to tell Amazonica to do that. You can provide the 'user data script' with the runInstances request if I remember correctly.

valtteri 2020-11-19T07:41:33.100300Z

It's been a while since I've been bootstrapping EC2-instances..

valtteri 2020-11-19T07:43:56.101300Z

Perhaps you can shortcut by setting up one of the instances manually and then saving it as a machine image (AMI) and then just telling Amazonica to launch an instance that uses that AMI

zackteo 2020-11-19T07:44:28.101900Z

unfortunately we need to start off from a base ami :x

valtteri 2020-11-19T07:45:36.103200Z

aws ec2 run-instances --image-id ami-abcd1234 --count 1 --instance-type m3.medium \
--key-name my-key-pair --subnet-id subnet-abcd1234 --security-group-ids sg-abcd1234 \
--user-data <file://my_script.txt>

valtteri 2020-11-19T07:45:50.103700Z

user-data script will be run when the instance launches

zackteo 2020-11-19T07:46:14.104200Z

Think they expect us to use boto3 from python but that's also just the aws sdk

zackteo 2020-11-19T07:46:19.104500Z

That's bash right?

valtteri 2020-11-19T07:46:23.104900Z

Yes

zackteo 2020-11-19T07:46:54.105700Z

Was trying to find that in the aws sdk but maybe ill just have to use bash

valtteri 2020-11-19T07:47:30.106300Z

☝️ there's how to do it with boto

zackteo 2020-11-19T07:47:35.106500Z

ooo! Thanks πŸ˜„

πŸ‘Œ 1
zackteo 2020-11-19T08:29:12.109800Z

I tried to find the equivalent on amazonica but to no avail - also considered using babashka with https://github.com/tzzh/pod-tzzh-aws but think it isn't worth the trouble ><. I'm just gonna approach this with boto3 after all πŸ˜… makes more sense to revisit the project and rewrite this part in Clojure if I am interested

viesti 2020-11-19T10:19:55.112Z

I'm thinking that it might be easier to do the setup with Terraform for example, is has great support for the AWS APIs and makes it easier to destroy resources after creation. There is some learning curve, but for a school project, one could use local state file store for example.

viesti 2020-11-19T10:58:06.112600Z

that said, I'm too biased, since I like Terraform too much πŸ™‚

borkdude 2020-11-19T11:49:28.113Z

@zackteo Shelling out to the AWS cli is pretty common with babashka

zackteo 2020-11-19T11:51:06.114600Z

@vlesti unfortunately am only allowed to use cloud formation at max ... would like to learn Terraform at some point!

zackteo 2020-11-19T11:54:00.118300Z

@borkdude ohhh. Are there any AWS and/or spark examples? Though I think that I'll likely end up sticking to bash given my use case of mainly installing dependencies and doing hadoop and spark setup

borkdude 2020-11-19T11:58:21.118800Z

@zackteo For example: https://github.com/borkdude/babashka/issues/575#issuecomment-712460781 I think @lukaszkorecki might also be doing something like this.

zackteo 2020-11-19T12:28:47.119600Z

okay!

zackteo 2020-11-19T12:32:25.122500Z

Btw, could someone explain how I might cloud formation fit into all this? I will also need to create a web app that links to MongoDB and MySQL so probably separate servers for each. I understand that cloud formation just makes things more declarative?

valtteri 2020-11-19T12:38:02.123400Z

Yes, CloudFormation is a JSON declaration of the AWS resources that you want to setup. It's pretty hard to grasp in the beginning, but I've learned to like it a lot over the years.

zackteo 2020-11-19T13:19:27.126100Z

If I set it up with cloud formation. How do I insert the instance with scripts I it want executed :o is there also a user-data part in the declaration?

zackteo 2020-11-19T13:19:44.126600Z

Or do I need to access the instances in another way?

valtteri 2020-11-19T14:47:09.127200Z

You embed the script into the cloudformation template JSON. Yes it's ugly. πŸ˜„

valtteri 2020-11-19T14:49:04.127700Z

"UserData": { "Fn::Base64": { "Fn::Join": [ "", 
  "#!/bin/bash\n",
  "echo 'doing stuff'\n"
] } }

lukasz 2020-11-19T15:03:11.128100Z

@borkdude yes, that's my current approach.

lukasz 2020-11-19T15:03:58.129100Z

FWIW I'd recommend Terraform over cloudformation as it covers 99% of the usecases with much nicer syntax and better primitives. And yes, you can specify user-data scripts there. Or use Packer to pre-bake machine images

2020-11-19T18:46:34.131900Z

When calling :GetExport with the cognitect aws api for apigateway I get the following response:

{:logref "4b35cdac-1783-4c1d-bdc2-ef84bc1fa68e",
 :message "Unable to build exporter: null",
 :cognitect.anomalies/category :cognitect.anomalies/incorrect}
Here is my invocation:
(aws-api/invoke
  client
  {:op      :GetExport
   :request {:restApiId  api-id
             :stageName  stage-name
             :exportType "swagger"}})
When I use the exact same arguments with boto3 it works, so I think the arguments are right. Anything seem wrong that I am missing?

2020-11-22T17:48:09.136100Z

@markbastian this will work:

(aws-api/invoke
 client
 {:op      :GetExport
  :request {:restApiId  api-id
            :stageName  stage-name
            :exportType "swagger"
            :accepts    "application/json"}})
I posted an issue https://github.com/cognitect-labs/aws-api/issues/158. Please keep the convo going there if you’re interested.

2020-11-30T17:56:50.164600Z

Thanks!