-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from Cox-Automotive/develop
Develop
- Loading branch information
Showing
8 changed files
with
202 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ glide.lock | |
# VSCode | ||
.vscode | ||
.DS_Store | ||
.terraform/ | ||
.terraform/ | ||
gpg/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/Cox-Automotive/alks-go" | ||
"github.com/hashicorp/terraform/helper/schema" | ||
"log" | ||
"strings" | ||
) | ||
|
||
func dataSourceAlksKeys() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceAlksKeysRead, | ||
Schema: map[string]*schema.Schema{ | ||
"access_key": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"secret_key": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"session_token": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"account": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"role": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceAlksKeysRead(d *schema.ResourceData, meta interface{}) error { | ||
log.Printf("[INFO] ALKS Keys Data Source Read") | ||
|
||
client := meta.(*alks.Client) | ||
resp, err := client.CreateIamSession() | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
// Return the information to user. | ||
_ = d.Set("access_key", resp.AccessKey) | ||
_ = d.Set("secret_key", resp.SecretKey) | ||
_ = d.Set("session_token", resp.SessionToken) | ||
_ = d.Set("account", client.AccountDetails.Account) | ||
_ = d.Set("role", strings.Split(client.AccountDetails.Role, "/")[0]) | ||
|
||
d.SetId(client.AccountDetails.Account) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
terraform { | ||
required_providers { | ||
alks = { | ||
source = "coxautoinc.com/engineering-enablement/alks" | ||
version = "1.4.4" | ||
} | ||
aws = { | ||
source = "hashicorp/aws" | ||
} | ||
} | ||
required_version = ">= 0.13" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters