Documentation
¶
Overview ¶
Package setlist provides utilities for managing AWS SSO configurations, including building and handling INI files for AWS profiles.
Index ¶
- Constants
- func ListAccounts(ctx context.Context, client OrganizationsClient) ([]types.Account, error)
- func ListPermissionsRequired() []string
- func ParseNicknameMapping(mapping string) (map[string]string, error)
- func PermissionSets(ctx context.Context, client SSOAdminClient, instanceArn string, ...) ([]types.PermissionSet, error)
- func SsoInstance(ctx context.Context, client SSOAdminClient) (types.InstanceMetadata, error)
- type ConfigFile
- type FileBuilder
- type OrganizationsClient
- type Profile
- type SSOAdminClient
Constants ¶
const DefaultNicknamePrefix string = "NoNickname"
DefaultNicknamePrefix defines the prefix used for accounts without explicit nicknames.
const SSOAccountIdKey string = "sso_account_id"
SSOAccountIdKey is the key used for specifying the AWS account ID in a profile.
const SSORegionKey string = "sso_region"
SSORegionKey is the attribute key for specifying the AWS region.
const SSORegistrationScopesKey string = "sso_registration_scopes"
SSORegistrationScopesKey defines the key for SSO registration scopes.
const SSORegistrationScopesValue string = "sso:account:access"
SSORegistrationScopesValue defines the default value for SSO registration scopes.
const SSORoleNameKey string = "sso_role_name"
SSORoleNameKey is the key used for defining the IAM role name.
const SSOSessionAttrKey string = "sso_session"
SSOSessionAttrKey is the attribute key for storing the SSO session name.
const SSOSessionSectionKey string = "sso-session"
SSOSessionSectionKey is the key used for defining an SSO session in configuration files.
const SSOStartUrlKey string = "sso_start_url"
SSOStartUrlKey is the attribute key for the AWS SSO start URL.
const VERSION string = "1.1.0"
Variables ¶
This section is empty.
Functions ¶
func ListAccounts ¶
ListAccounts retrieves all accounts within an AWS Organization using the provided Organizations client.
func ListPermissionsRequired ¶ added in v1.2.0
func ListPermissionsRequired() []string
func ParseNicknameMapping ¶
ParseNicknameMapping parses a nickname mapping string into a map. The expected format is "accountID1=nickname1,accountID2=nickname2". Returns an error if the format is invalid.
func PermissionSets ¶
func PermissionSets(ctx context.Context, client SSOAdminClient, instanceArn string, accountId string) ([]types.PermissionSet, error)
PermissionSets retrieves the list of permission sets provisioned to an account.
func SsoInstance ¶
func SsoInstance(ctx context.Context, client SSOAdminClient) (types.InstanceMetadata, error)
SsoInstance retrieves the SSO instance metadata. AWS SSO allows only a single instance per organization.
Types ¶
type ConfigFile ¶
type ConfigFile struct {
SessionName string // Name of the SSO session
IdentityStoreId string // The unique identity store ID
FriendlyName string // Alt name used for the SSO instance
Region string // AWS region
Profiles []Profile // List of AWS profiles
NicknameMapping map[string]string // Mapping of account IDs to nicknames
}
ConfigFile represents the structure of the configuration file, including session details, profiles, and nickname mappings.
func (ConfigFile) HasNickname ¶
func (c ConfigFile) HasNickname(accountId string) bool
HasNickname determines whether an account has a mapped nickname.
func (*ConfigFile) StartURL ¶
func (c *ConfigFile) StartURL() string
StartURL constructs the AWS SSO start URL based on the IdentityStoreId or FriendlyName.
type FileBuilder ¶
type FileBuilder struct {
Config ConfigFile
}
FileBuilder is responsible for generating an INI file based on the provided configuration.
func NewFileBuilder ¶
func NewFileBuilder(configFile ConfigFile) FileBuilder
NewFileBuilder creates a new FileBuilder instance with the given configuration.
func (*FileBuilder) Build ¶
func (f *FileBuilder) Build() (*ini.File, error)
Build generates an INI file based on the configuration. It adds a default section, an SSO section, and profile sections for each configured profile. If a nickname mapping exists, it creates an additional profile section for the nickname.
type OrganizationsClient ¶ added in v1.2.0
type OrganizationsClient interface {
ListAccounts(ctx context.Context, params *organizations.ListAccountsInput, optFns ...func(*organizations.Options)) (*organizations.ListAccountsOutput, error)
}
Define interface for the Organizations client to make testing easier
type Profile ¶
type Profile struct {
Name string
Description string
SessionDuration string
SessionName string
AccountId string
RoleName string
}
Profile represents an AWS SSO profile configuration.
type SSOAdminClient ¶ added in v1.2.0
type SSOAdminClient interface {
ListInstances(ctx context.Context, params *ssoadmin.ListInstancesInput, optFns ...func(*ssoadmin.Options)) (*ssoadmin.ListInstancesOutput, error)
ListPermissionSetsProvisionedToAccount(ctx context.Context, params *ssoadmin.ListPermissionSetsProvisionedToAccountInput, optFns ...func(*ssoadmin.Options)) (*ssoadmin.ListPermissionSetsProvisionedToAccountOutput, error)
DescribePermissionSet(ctx context.Context, params *ssoadmin.DescribePermissionSetInput, optFns ...func(*ssoadmin.Options)) (*ssoadmin.DescribePermissionSetOutput, error)
}
Define interface for the SSO Admin client to make testing easier