Skip to content

Commit

Permalink
Amend README
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Adrian Samfira <[email protected]>
  • Loading branch information
gabriel-samfira committed Jun 12, 2024
1 parent beb3f5f commit 3d11c01
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 31 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ region = "eu-central-1"
subnet_id = "sample_subnet_id"

[credentials]
credential_type = "access_key"
# Allowed values are: static, role
# When using IAM roles, you can omit the [credentials.static] section
credential_type = "static"
[credentials.static]
access_key_id = "sample_access_key_id"
secret_access_key = "sample_secret_access_key"
session_token = "sample_session_token"
Expand Down
8 changes: 4 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (
type AWSCredentialType string

const (
AWSCredentialTypeStaticCredentials AWSCredentialType = "static"
AWSCredentialTypeRole AWSCredentialType = "role"
AWSCredentialTypeStatic AWSCredentialType = "static"
AWSCredentialTypeRole AWSCredentialType = "role"
)

// NewConfig returns a new Config
Expand Down Expand Up @@ -99,7 +99,7 @@ type Credentials struct {

func (c Credentials) Validate() error {
switch c.CredentialType {
case AWSCredentialTypeStaticCredentials:
case AWSCredentialTypeStatic:
return c.StaticCredentials.Validate()
case AWSCredentialTypeRole:
case "":
Expand All @@ -118,7 +118,7 @@ func (c Config) GetAWSConfig(ctx context.Context) (aws.Config, error) {
var cfg aws.Config
var err error
switch c.Credentials.CredentialType {
case AWSCredentialTypeStaticCredentials:
case AWSCredentialTypeStatic:
cfg, err = config.LoadDefaultConfig(ctx,
config.WithCredentialsProvider(
credentials.NewStaticCredentialsProvider(
Expand Down
16 changes: 8 additions & 8 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestConfigValidate(t *testing.T) {
name: "valid config",
c: &Config{
Credentials: Credentials{
CredentialType: AWSCredentialTypeStaticCredentials,
CredentialType: AWSCredentialTypeStatic,
StaticCredentials: StaticCredentials{
AccessKeyID: "access_key_id",
SecretAccessKey: "secret_access_key",
Expand All @@ -48,7 +48,7 @@ func TestConfigValidate(t *testing.T) {
name: "missing subnet_id",
c: &Config{
Credentials: Credentials{
CredentialType: AWSCredentialTypeStaticCredentials,
CredentialType: AWSCredentialTypeStatic,
StaticCredentials: StaticCredentials{
AccessKeyID: "access_key_id",
SecretAccessKey: "secret_access_key",
Expand All @@ -63,7 +63,7 @@ func TestConfigValidate(t *testing.T) {
name: "missing region",
c: &Config{
Credentials: Credentials{
CredentialType: AWSCredentialTypeStaticCredentials,
CredentialType: AWSCredentialTypeStatic,
StaticCredentials: StaticCredentials{
AccessKeyID: "access_key_id",
SecretAccessKey: "secret_access_key",
Expand Down Expand Up @@ -116,7 +116,7 @@ func TestCredentialsValidate(t *testing.T) {
{
name: "valid credentials",
c: Credentials{
CredentialType: AWSCredentialTypeStaticCredentials,
CredentialType: AWSCredentialTypeStatic,
StaticCredentials: StaticCredentials{
AccessKeyID: "access_key_id",
SecretAccessKey: "secret_access_key",
Expand All @@ -128,7 +128,7 @@ func TestCredentialsValidate(t *testing.T) {
{
name: "missing access_key_id",
c: Credentials{
CredentialType: AWSCredentialTypeStaticCredentials,
CredentialType: AWSCredentialTypeStatic,
StaticCredentials: StaticCredentials{
AccessKeyID: "",
SecretAccessKey: "secret_access_key",
Expand All @@ -140,7 +140,7 @@ func TestCredentialsValidate(t *testing.T) {
{
name: "missing secret_access_key",
c: Credentials{
CredentialType: AWSCredentialTypeStaticCredentials,
CredentialType: AWSCredentialTypeStatic,
StaticCredentials: StaticCredentials{
AccessKeyID: "access_key_id",
SecretAccessKey: "",
Expand All @@ -152,7 +152,7 @@ func TestCredentialsValidate(t *testing.T) {
{
name: "missing session_token",
c: Credentials{
CredentialType: AWSCredentialTypeStaticCredentials,
CredentialType: AWSCredentialTypeStatic,
StaticCredentials: StaticCredentials{
AccessKeyID: "access_key_id",
SecretAccessKey: "secret_access_key",
Expand Down Expand Up @@ -205,7 +205,7 @@ func TestNewConfig(t *testing.T) {
require.NoError(t, err, "NewConfig() should not have returned an error")
require.Equal(t, &Config{
Credentials: Credentials{
CredentialType: AWSCredentialTypeStaticCredentials,
CredentialType: AWSCredentialTypeStatic,
StaticCredentials: StaticCredentials{
AccessKeyID: "access_key_id",
SecretAccessKey: "secret",
Expand Down
16 changes: 8 additions & 8 deletions internal/client/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestStartInstance(t *testing.T) {
Region: "us-west-2",
SubnetID: "subnet-1234567890abcdef0",
Credentials: config.Credentials{
CredentialType: config.AWSCredentialTypeStaticCredentials,
CredentialType: config.AWSCredentialTypeStatic,
StaticCredentials: config.StaticCredentials{
AccessKeyID: "AccessKeyID",
SecretAccessKey: "SecretAccessKey",
Expand Down Expand Up @@ -65,7 +65,7 @@ func TestStopInstance(t *testing.T) {
Region: "us-west-2",
SubnetID: "subnet-1234567890abcdef0",
Credentials: config.Credentials{
CredentialType: config.AWSCredentialTypeStaticCredentials,
CredentialType: config.AWSCredentialTypeStatic,
StaticCredentials: config.StaticCredentials{
AccessKeyID: "AccessKeyID",
SecretAccessKey: "SecretAccessKey",
Expand Down Expand Up @@ -95,7 +95,7 @@ func TestFindInstances(t *testing.T) {
Region: "us-west-2",
SubnetID: "subnet-1234567890abcdef0",
Credentials: config.Credentials{
CredentialType: config.AWSCredentialTypeStaticCredentials,
CredentialType: config.AWSCredentialTypeStatic,
StaticCredentials: config.StaticCredentials{
AccessKeyID: "AccessKeyID",
SecretAccessKey: "SecretAccessKey",
Expand Down Expand Up @@ -154,7 +154,7 @@ func TestFindOneInstanceWithName(t *testing.T) {
Region: "us-west-2",
SubnetID: "subnet-1234567890abcdef0",
Credentials: config.Credentials{
CredentialType: config.AWSCredentialTypeStaticCredentials,
CredentialType: config.AWSCredentialTypeStatic,
StaticCredentials: config.StaticCredentials{
AccessKeyID: "AccessKeyID",
SecretAccessKey: "SecretAccessKey",
Expand Down Expand Up @@ -207,7 +207,7 @@ func TestFindOneInstanceWithID(t *testing.T) {
Region: "us-west-2",
SubnetID: "subnet-1234567890abcdef0",
Credentials: config.Credentials{
CredentialType: config.AWSCredentialTypeStaticCredentials,
CredentialType: config.AWSCredentialTypeStatic,
StaticCredentials: config.StaticCredentials{
AccessKeyID: "AccessKeyID",
SecretAccessKey: "SecretAccessKey",
Expand Down Expand Up @@ -249,7 +249,7 @@ func TestGetInstance(t *testing.T) {
Region: "us-west-2",
SubnetID: "subnet-1234567890abcdef0",
Credentials: config.Credentials{
CredentialType: config.AWSCredentialTypeStaticCredentials,
CredentialType: config.AWSCredentialTypeStatic,
StaticCredentials: config.StaticCredentials{
AccessKeyID: "AccessKeyID",
SecretAccessKey: "SecretAccessKey",
Expand Down Expand Up @@ -288,7 +288,7 @@ func TestTerminateInstance(t *testing.T) {
Region: "us-west-2",
SubnetID: "subnet-1234567890abcdef0",
Credentials: config.Credentials{
CredentialType: config.AWSCredentialTypeStaticCredentials,
CredentialType: config.AWSCredentialTypeStatic,
StaticCredentials: config.StaticCredentials{
AccessKeyID: "AccessKeyID",
SecretAccessKey: "SecretAccessKey",
Expand Down Expand Up @@ -336,7 +336,7 @@ func TestCreateRunningInstance(t *testing.T) {
Region: "us-west-2",
SubnetID: "subnet-1234567890abcdef0",
Credentials: config.Credentials{
CredentialType: config.AWSCredentialTypeStaticCredentials,
CredentialType: config.AWSCredentialTypeStatic,
StaticCredentials: config.StaticCredentials{
AccessKeyID: "AccessKeyID",
SecretAccessKey: "SecretAccessKey",
Expand Down
2 changes: 1 addition & 1 deletion internal/spec/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestGetRunnerSpecFromBootstrapParams(t *testing.T) {

config := &config.Config{
Credentials: config.Credentials{
CredentialType: config.AWSCredentialTypeStaticCredentials,
CredentialType: config.AWSCredentialTypeStatic,
StaticCredentials: config.StaticCredentials{
AccessKeyID: "AccessKeyID",
SecretAccessKey: "SecretAccessKey",
Expand Down
18 changes: 9 additions & 9 deletions provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestCreateInstance(t *testing.T) {
Region: "us-east-1",
SubnetID: "subnet-123456",
Credentials: config.Credentials{
CredentialType: config.AWSCredentialTypeStaticCredentials,
CredentialType: config.AWSCredentialTypeStatic,
StaticCredentials: config.StaticCredentials{
AccessKeyID: "AccessKeyID",
SecretAccessKey: "SecretAccessKey",
Expand Down Expand Up @@ -109,7 +109,7 @@ func TestDeleteInstanceWithID(t *testing.T) {
Region: "us-east-1",
SubnetID: "subnet-123456",
Credentials: config.Credentials{
CredentialType: config.AWSCredentialTypeStaticCredentials,
CredentialType: config.AWSCredentialTypeStatic,
StaticCredentials: config.StaticCredentials{
AccessKeyID: "AccessKeyID",
SecretAccessKey: "SecretAccessKey",
Expand Down Expand Up @@ -140,7 +140,7 @@ func TestDeleteInstanceWithName(t *testing.T) {
Region: "us-east-1",
SubnetID: "subnet-123456",
Credentials: config.Credentials{
CredentialType: config.AWSCredentialTypeStaticCredentials,
CredentialType: config.AWSCredentialTypeStatic,
StaticCredentials: config.StaticCredentials{
AccessKeyID: "AccessKeyID",
SecretAccessKey: "SecretAccessKey",
Expand Down Expand Up @@ -204,7 +204,7 @@ func TestGetInstanceWithID(t *testing.T) {
Region: "us-east-1",
SubnetID: "subnet-123456",
Credentials: config.Credentials{
CredentialType: config.AWSCredentialTypeStaticCredentials,
CredentialType: config.AWSCredentialTypeStatic,
StaticCredentials: config.StaticCredentials{
AccessKeyID: "AccessKeyID",
SecretAccessKey: "SecretAccessKey",
Expand Down Expand Up @@ -276,7 +276,7 @@ func TestGetInstanceWithName(t *testing.T) {
Region: "us-east-1",
SubnetID: "subnet-123456",
Credentials: config.Credentials{
CredentialType: config.AWSCredentialTypeStaticCredentials,
CredentialType: config.AWSCredentialTypeStatic,
StaticCredentials: config.StaticCredentials{
AccessKeyID: "AccessKeyID",
SecretAccessKey: "SecretAccessKey",
Expand Down Expand Up @@ -363,7 +363,7 @@ func TestListInstances(t *testing.T) {
Region: "us-east-1",
SubnetID: "subnet-123456",
Credentials: config.Credentials{
CredentialType: config.AWSCredentialTypeStaticCredentials,
CredentialType: config.AWSCredentialTypeStatic,
StaticCredentials: config.StaticCredentials{
AccessKeyID: "AccessKeyID",
SecretAccessKey: "SecretAccessKey",
Expand Down Expand Up @@ -452,7 +452,7 @@ func TestStop(t *testing.T) {
Region: "us-east-1",
SubnetID: "subnet-123456",
Credentials: config.Credentials{
CredentialType: config.AWSCredentialTypeStaticCredentials,
CredentialType: config.AWSCredentialTypeStatic,
StaticCredentials: config.StaticCredentials{
AccessKeyID: "AccessKeyID",
SecretAccessKey: "SecretAccessKey",
Expand Down Expand Up @@ -482,7 +482,7 @@ func TestStartStoppedInstance(t *testing.T) {
Region: "us-east-1",
SubnetID: "subnet-123456",
Credentials: config.Credentials{
CredentialType: config.AWSCredentialTypeStaticCredentials,
CredentialType: config.AWSCredentialTypeStatic,
StaticCredentials: config.StaticCredentials{
AccessKeyID: "AccessKeyID",
SecretAccessKey: "SecretAccessKey",
Expand Down Expand Up @@ -534,7 +534,7 @@ func TestStartStoppingInstance(t *testing.T) {
Region: "us-east-1",
SubnetID: "subnet-123456",
Credentials: config.Credentials{
CredentialType: config.AWSCredentialTypeStaticCredentials,
CredentialType: config.AWSCredentialTypeStatic,
StaticCredentials: config.StaticCredentials{
AccessKeyID: "AccessKeyID",
SecretAccessKey: "SecretAccessKey",
Expand Down

0 comments on commit 3d11c01

Please sign in to comment.