Comments (4)
Just curious (and I know it's more layers) but did you try https://hexdocs.pm/aws/AWS.AutoScaling.html
I also wish the ec2 api would be support tho
from aws-elixir.
In the meanwhile I am using this to get my required API call.
defmodule AWS.EC2 do
def describe_network_interfaces(client, input, options \\ []) do
request(client, "DescribeNetworkInterfaces", input, options)
end
@spec request(AWS.Client.t(), binary(), map(), list()) ::
{:ok, Poison.Parser.t() | nil, Poison.Response.t()}
| {:error, Poison.Parser.t()}
| {:error, HTTPoison.Error.t()}
defp request(client, action, input, options) do
client = %{client | service: "ec2"}
host = build_host("ec2", client)
url = build_url(host, client)
headers = [
{"Host", host},
{"Content-Type", "application/x-www-form-urlencoded"}
]
input = Map.merge(input, %{"Action" => action, "Version" => "2016-11-15"})
payload = AWS.Util.encode_query(input)
headers = AWS.Request.sign_v4(client, "POST", url, headers, payload)
case HTTPoison.post(url, payload, headers, options) do
{:ok, %HTTPoison.Response{status_code: 200, body: ""} = response} ->
{:ok, nil, response}
{:ok, %HTTPoison.Response{status_code: 200, body: body} = response} ->
{:ok, AWS.Util.decode_xml(body), response}
{:ok, %HTTPoison.Response{body: body}} ->
error = AWS.Util.decode_xml(body)
{:error, error}
{:error, %HTTPoison.Error{reason: reason}} ->
{:error, %HTTPoison.Error{reason: reason}}
end
end
defp build_host(_endpoint_prefix, %{region: "local"}) do
"localhost"
end
defp build_host(endpoint_prefix, %{region: region, endpoint: endpoint}) do
"#{endpoint_prefix}.#{region}.#{endpoint}"
end
defp build_url(host, %{:proto => proto, :port => port}) do
"#{proto}://#{host}:#{port}/"
end
end
from aws-elixir.
defmodule AWS.EC2 do
alias AWS.Request
def metadata do
%AWS.ServiceMetadata{
api_version: "2016-11-15",
content_type: "text/xml",
endpoint_prefix: "ec2",
global?: false,
protocol: "query",
signing_name: "ec2"
}
end
def describe_instances(client, input, options \\ []) do
Request.request_post(client, metadata(), "DescribeInstances", input, options)
end
end
seems to work for me:
> iex
Erlang/OTP 25 [RELEASE CANDIDATE 2] [erts-13.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]
Interactive Elixir (1.14.0-dev) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Mix.install [:aws, :jason, :hackney]
iex(2)> defmodule AWS.EC2 do
...(2)> alias AWS.Request
...(2)>
...(2)> def metadata do
...(2)> %AWS.ServiceMetadata{
...(2)> api_version: "2016-11-15",
...(2)> content_type: "text/xml",
...(2)> endpoint_prefix: "ec2",
...(2)> global?: false,
...(2)> protocol: "query",
...(2)> signing_name: "ec2"
...(2)> }
...(2)> end
...(2)>
...(2)> def describe_instances(client, input, options \\ []) do
...(2)> Request.request_post(client, metadata(), "DescribeInstances", input, options)
...(2)> end
...(2)> end
iex(3)> client = AWS.Client.create("eu-north-1")
iex(4)> AWS.EC2.describe_instances(client, _input = %{})
{:ok,
%{
"DescribeInstancesResponse" => %{
"requestId" => "57587f0e-31f9-4d70-8f27-87b738f39f2b",
"reservationSet" => %{
"item" => [
%{
"groupSet" => :none,
"instancesSet" => %{
"item" => %{
"tagSet" => %{
# ...
from aws-elixir.
I've created two pull requests that would add support for ec2.
aws-beam/aws-codegen#100
#170
from aws-elixir.
Related Issues (20)
- Potential breaking changes not documented on CHANGELOG.md HOT 2
- Add Support for AWS Textract Analyzing ID Documents feature HOT 2
- ~/.aws/credentials parsing, session layer ? HOT 5
- AWS Rekognition not working as per the docs HOT 2
- Implement automatic retries in aws-elixir
- Bug: SQS send_batch_message error encoding list of Entries HOT 5
- Need help with assuming roles with tags. HOT 11
- nxdomain errror when using AWS.Location.search_place_index_for_text HOT 7
- Loading issue with modules that shouldn't be generated: AWS.Cloudsearchdomain and AWS.Importexport (Instead of CamelCase counterparts) HOT 2
- AWS.ApiGatewayManagementApi, URL and headers with stage HOT 1
- S3 put_object returns {:error, :timeout} but uploads file correctly HOT 5
- `AWS.S3.delete_objects` content md5 header HOT 5
- SelectObjectContent response HOT 1
- `AWS.STS.assume_role_with_web_identity` should not rely on access_key_id and secret_access_key
- Error calling textractor HOT 3
- Setting endpoint to `amazonaws.com` results in different behaviour as not setting an endpoint HOT 1
- AWS.S3.get_object always returns {:error, :timeout} with hackney > 1.18.1 HOT 5
- Streaming response handling HOT 10
- `put_bucket_cors` request is incorrect HOT 5
- Setup pipeline to automatically roll out new releases upon tagging
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-elixir.