Fork me on GitHub
#aws
<
2022-07-18
>
seepel03:07:28

Hi there, I'm trying to use the java aws sdk to initialize a SecretsManagerClient following along with examples I found online this is the code I expect to work

(-> (SecretsManagerClient/builder)
                   (.region (Region/of "us-west-2"))
                   .build)
But I get the following error
Execution error (IllegalArgumentException) at user/eval18745 (form-init12695352935497667069.clj:1).
No matching method of found taking 1 args for class java.lang.Class
However, if I import the class at the repl, calling
(Region/of "us-west-2")
does indeed work correctly. Does anyone have experience with something like this? EDIT: here is another more clear error message that I also got:
No matching method of found taking 1 args for class com.amazonaws.regions.Region

hiredman03:07:46

My guess is when you "import the class at the repl" you are importing a different class

seepel03:07:02

Ohhhh, indeed. In my code it is imported as

(com.amazon.regions Region)
Whereas at the repl I imported
(software.amazon.awssdk.regions Region)
The latter doesn't work in my namespace though... Even though I guess I don't really understand what is going on, I think I did sort out that I can get the region like this...
(-> (SecretsManagerClient/builder)
                   (.region (Region/getRegion Regions/US_WEST_2))
                   .build)
Thank you for the tip @hiredman!

seepel03:07:34

Oh gosh, maybe not.

class com.amazonaws.regions.Region cannot be cast to class software.amazon.awssdk.regions.Region (com.amazonaws.regions.Region and software.amazon.awssdk.regions.Region are in unnamed module of loader 'app')

seepel03:07:55

I must've had a typo, I just deleted everything and very carefully added it back in. Thank you for the duckie

Benjamin16:07:55

Does anybody have experience with redshift and sorting the data correctly, so queries stay fast? General RDB advice is welcome

Drew Verlee22:07:38

advice specific to redshift or in general? In general the only way something can traverse something fast is if it's close together. As in, you have to store things in the sorted order. In database speak, that's indexing. space for time.

👍 1
Drew Verlee22:07:39

In cloudformation, when your spinning up resources, if one requires the ARN of another how do you handle that? like, how do they do references?

Drew Verlee22:07:47

i'll figure it out from here i'm sure, but this example is funny because it has a ref but not the important bit where it shows the other end of the edge.

MyEIP:
  Type: "AWS::EC2::EIP"
  Properties:
    InstanceId: !Ref MyEC2Instance # <--- where is this declared?

jjttjj22:07:55

Depending on the resource type, it may or may not return what you need for the other resource parameter. Sometimes you'll need to use Fn::GetAtt instead. I find i consult this a lot https://theburningmonk.com/cloudformation-ref-and-getatt-cheatsheet/

jjttjj22:07:04

The Ref argument refers to either the name you give the resource (ie, names on the level of MyEIP in that example, MyEC2Instance would be a sibling ), or the name of a parameter of your template. (and maybe some more stuff I'm forgetting)

Drew Verlee22:07:34

This is how cloudformation makes me feel on the inside.

😆 1
jjttjj22:07:24

Haha yup it definitely feels like coding in json a bit, wait til you get to if statements/conditionals

jjttjj22:07:04

I've been on an ongoing deep dive in to cloudformation. Overall I like it, after getting comfortable with the ways to do things. In the end I like that it's just JSON and it's nice that you can just stick some edn in a clojure file and break it up and add as many helpers as you want before calling some json library to write it out as json.

Drew Verlee22:07:40

I'm certainly glad it's an option! I wonder if there are any clojure wrappers that do some really fun runtime analysis to try and help you intelligent build and update cloudformation though. You could pull the api and return suggestions in the editor. etc... I know you can output CF from the design tool, but it doesn't seem to actually help you with anything other then putting pictures together. which is odd... Is "taskdefination" the name of the instance of this task below?

taskdefinition: 
  Type: AWS::ECS::TaskDefinition

jjttjj22:07:02

{:Resources {"<your names>" {:Type "" :Properties {...}} ...}

jjttjj22:07:23

There are a few attempts at tooling in clojure ie https://github.com/brabster/crucible, but I don' think it has that many resource types supported and isn't actively being updated

jjttjj22:07:08

the specification for everything is here though so it shouldn't be too hard to get an auto-complete thing going https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-resource-specification.html

Drew Verlee22:07:43

interesting, ill have to take a look. If for no other reason then it will probably help me conceptualize whats going on.