I'm using amazonica to create an ami and then launch an instance from the ami when it's ready.
The problem I'm having with amazonica is that it has about zero documentation (that I can find), apart from what's on readme. And what's on ready is very little and covers very little.
I can currently successfully look at running instances, grab latest / required instance, create an AMI off of it, wait until that's ready, and then launch that instance.
Only, the (run-instance)
method takes in I don't know what arguments. Looking at the java api doc I have figured out most of parameters with some trial and error but I still need to set a few more things.
Where can I find what parameters to pass to this function?
Currently, I have:
(run-instances :image-id ami-id
:min-count 1
:max-count 1
:instance-type "t2.small"
:key-name "api-key-pair"
:sercurity-groups ["sg-1a2b3c4d"]
;:vpc-id "vpc-a1b2c3d4"
:subnet-id "subnet-a1b2c3d4"
:monitoring true
:ebs-optimized false
:tag [{:value instance-name
:key "Name"}])
And this sets most things. But I can't figure out how to set:
name: "prod-1.0"
security groups. I've tried the one above, and this:
:security-groups [{:group-id "sg-1a2b3c4d"
:group-name "SG_STRICT"}]
but no use. Either the instance has default group, or, I get a strange errors like
...AmazonServiceException: The specified instance type can only be used in a VPC. A subnet ID or network interface ID is required to carry out the request
or
....s.AmazonServiceException: The security group '{:group-id "sg-1a2b3c4d", :group-name "SG_STRICT"}' does not exist
I've gone through that whole doc page a couple of times and can't find any other sensible options / keywords to pass.
I also want to start the instance with auto-assign-public-ip option too.
The source doesn't reveal much on amazonica, unfortunately, as the doc says it uses reflections heavily and tests aren't very elaborate.
so How do I set a security group and tags for this, please?
For the groups the example on the readme uses the name :groups
rather than security groups and I don't think you need to specify both the id and name, just the name should be sufficient. I don't do this because in practice I always creates an ASG and launch configuration and then put it into an LB. The examples form amazonica look like this:
:groups [{:group-name "cx", :group-id "sg-38f45150"}],
and when specifying it in a launch configuration it looks like this:
:security-groups ["Email-prod" "marker.production"]
The best resource for using amazonica is the AWS rest API documentation, and your not finding the parameter on instance create because it's in it's own call. First start the instance creation, then once you get the instance id from that response make another call to tag the instance.
(ec2/create-tags
{:resources ["i-cb2AAA3a"]
:tags [{:key "hello"
:value "world"}]})
Some tips on reading these docs:
&Tag.1.Key=webserver
&Tag.1.Value=
&Tag.2.Key=stack
&Tag.2.Value=Production
can be written as arrays