Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
0a174089
Commit
0a174089
authored
Jun 13, 2017
by
Justin Santa Barbara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use awsInstanceID to query instances
Also reuse existing mapping code, rather than reimplementing. Issue #47394
parent
8aad321d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
aws.go
pkg/cloudprovider/providers/aws/aws.go
+0
-0
instances.go
pkg/cloudprovider/providers/aws/instances.go
+20
-0
No files found.
pkg/cloudprovider/providers/aws/aws.go
View file @
0a174089
This diff is collapsed.
Click to expand it.
pkg/cloudprovider/providers/aws/instances.go
View file @
0a174089
...
...
@@ -22,6 +22,7 @@ import (
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
)
// awsInstanceID represents the ID of the instance in the AWS API, e.g. i-12345678
...
...
@@ -78,3 +79,22 @@ func (name kubernetesInstanceID) mapToAWSInstanceID() (awsInstanceID, error) {
return
awsInstanceID
(
awsID
),
nil
}
// Gets the full information about this instance from the EC2 API
func
describeInstance
(
ec2Client
EC2
,
instanceID
awsInstanceID
)
(
*
ec2
.
Instance
,
error
)
{
request
:=
&
ec2
.
DescribeInstancesInput
{
InstanceIds
:
[]
*
string
{
instanceID
.
awsString
()},
}
instances
,
err
:=
ec2Client
.
DescribeInstances
(
request
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
instances
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"no instances found for instance: %s"
,
instanceID
)
}
if
len
(
instances
)
>
1
{
return
nil
,
fmt
.
Errorf
(
"multiple instances found for instance: %s"
,
instanceID
)
}
return
instances
[
0
],
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment