Documentation
¶
Index ¶
- Constants
- Variables
- func BucketExists(ctx context.Context, c *Credentials, region string, bucketName string) bool
- func CreateAdminPolicyIfNotExists(ctx context.Context, c *Credentials, region string, accountID string, ...) error
- func CreateBucket(ctx context.Context, c *Credentials, region string, bucketName string) error
- func CreateKmsKey(ctx context.Context, c *Credentials, region string, keyAlias string, ...) (string, error)
- func GetCallerIdentity(ctx context.Context) (out *sts.GetCallerIdentityOutput, err error)
- func GetClusterEndpoint(ctx context.Context, c *Credentials, region string, clusterName string) (string, error)
- func GetClusterInfo(ctx context.Context, c *Credentials, region string, clusterName string) (endpoint string, caCert string, err error)
- func GetEKSToken(ctx context.Context, c *Credentials, region string, clusterName string) (string, error)
- func IamPermissionBoundaryCondition() yaml.Node
- func IamResourceWildcards() []yaml.Node
- func KmsKeyExists(ctx context.Context, c *Credentials, region string, keyId string) bool
- func S3ResourceAccountCondition() yaml.Node
- func SsmSendCommand(ctx context.Context, c *Credentials, region string, instanceId string, ...) error
- type Action
- func AcmActions() []Action
- func BedrockActions() []Action
- func BillingActions() []Action
- func CloudwatchActions() []Action
- func ComputeOptimizerActions() []Action
- func DirectoryServiceActions() []Action
- func Ec2Actions() []Action
- func EcrActions() []Action
- func EcsActions() []Action
- func EfsActions() []Action
- func EksActions() []Action
- func ElbActions() []Action
- func EventsActions() []Action
- func FirehoseActions() []Action
- func FsxActions() []Action
- func IamWildcardActions() []Action
- func KmsActions() []Action
- func LogActions() []Action
- func OrganizationActions() []Action
- func PricingActions() []Action
- func RdsActions() []Action
- func ResourceExplorerActions() []Action
- func Route53Actions() []Action
- func SecretsManagerActions() []Action
- func ShieldActions() []Action
- func SqsActions() []Action
- func SsmActions() []Action
- func StsActions() []Action
- func TagActions() []Action
- func Wafv2Actions() []Action
- type Credentials
- type ManagedPolicy
- type Policy
- type PolicyDocument
- type PolicyRef
- type PolicyStatement
- type Principal
- type ProxySession
- type Registry
- func (r Registry) GetAuthForCredentials(ctx context.Context, c types.Credentials) (username string, password string, err error)
- func (r Registry) GetLatestDigestForRepository(ctx context.Context, c types.Credentials, repository string) (string, error)
- func (r Registry) GetLatestImageForRepository(ctx context.Context, c types.Credentials, repository string) (details types.ImageDetails, err error)
- func (r Registry) Region() string
- func (r Registry) RegistryURI() string
- type Role
- type SecretStore
- func (s *SecretStore) CreateSecret(ctx context.Context, c types.Credentials, secretName string, ...) error
- func (s *SecretStore) CreateSecretIfNotExists(ctx context.Context, c types.Credentials, secretName string, secret any) (err error)
- func (s *SecretStore) EnsureWorkloadSecret(ctx context.Context, c types.Credentials, workloadName string, secret any) (err error)
- func (s *SecretStore) GetSecretValue(ctx context.Context, c types.Credentials, secretName string) (string, error)
- func (s *SecretStore) PutSecretValue(ctx context.Context, c types.Credentials, secretName string, ...) error
- func (s *SecretStore) SecretExists(ctx context.Context, c types.Credentials, secretName string) bool
- type Target
- func (t Target) BastionId(ctx context.Context) (string, error)
- func (t Target) CloudProvider() types.CloudProvider
- func (t Target) ControlRoom() bool
- func (t Target) CreateAdminPolicyAsResource() bool
- func (t Target) Credentials(ctx context.Context) (types.Credentials, error)
- func (t Target) HashName() string
- func (t Target) Name() string
- func (t Target) PulumiBackendUrl() string
- func (t Target) PulumiSecretsProviderKey() string
- func (t Target) Region() string
- func (t Target) Registry() types.Registry
- func (t Target) SecretStore() types.SecretStore
- func (t Target) Sites() map[string]types.SiteConfig
- func (t Target) StateBucketName() string
- func (t Target) TailscaleEnabled() bool
- func (t Target) Type() types.TargetType
Constants ¶
const ( ProfileEnvVar = "AWS_PROFILE" AccessKeyIdEnvVar = "AWS_ACCESS_KEY_ID" SecretAccessKeyEnvVar = "AWS_SECRET_ACCESS_KEY" SessionTokenEnvVar = "AWS_SESSION_TOKEN" )
const ( SSMStartSSHSessionDocumentName = "AWS-StartSSHSession" SSMRunShellDocumentName = "AWS-RunShellScript" SessionManagerPluginDir = "/usr/local/bin" )
const (
WILDCARD = "*"
)
Variables ¶
var ErrECRDeprecated = errors.New("ECR functionality has been removed; images are now pulled from public Docker Hub")
ErrECRDeprecated is returned when ECR functionality is accessed. ECR has been removed in favor of public Docker Hub images.
Functions ¶
func BucketExists ¶
func CreateAdminPolicyIfNotExists ¶
func CreateAdminPolicyIfNotExists(ctx context.Context, c *Credentials, region string, accountID string, policyName string) error
CreateAdminPolicyIfNotExists creates the PositTeamDedicatedAdmin IAM policy if it doesn't already exist. This policy is used as both a permissions boundary and attached managed policy for PTD roles. It's particularly important for workloads using custom_role where the standard admin setup doesn't automatically create the policy.
Returns nil if the policy already exists or was successfully created. Returns an error if:
- The custom role lacks permission to check for or create policies (AccessDenied)
- Network or transient AWS API errors occur (AWS SDK handles retries automatically)
- Policy document marshaling fails
func CreateBucket ¶
func CreateKmsKey ¶
func GetCallerIdentity ¶
func GetCallerIdentity(ctx context.Context) (out *sts.GetCallerIdentityOutput, err error)
GetCallerIdentity returns the caller's identity
func GetClusterEndpoint ¶
func GetClusterInfo ¶
func GetClusterInfo(ctx context.Context, c *Credentials, region string, clusterName string) (endpoint string, caCert string, err error)
GetClusterInfo retrieves the endpoint and certificate authority data for an EKS cluster
func GetEKSToken ¶
func GetEKSToken(ctx context.Context, c *Credentials, region string, clusterName string) (string, error)
GetEKSToken generates an EKS-compatible token using STS presigned URLs
func IamPermissionBoundaryCondition ¶
IamPermissionBoundaryCondition returns a CloudFormation-compatible YAML condition node that enforces the PositTeamDedicatedAdmin policy as a permissions boundary. This condition is used in IAM policy statements to ensure that any IAM role or user created by PTD must have the admin policy set as their permissions boundary.
The returned YAML node structure represents:
Condition:
StringEquals:
iam:PermissionsBoundary:
- !Sub 'arn:aws:iam::${AWS::AccountId}:policy/PositTeamDedicatedAdmin'
This prevents privilege escalation by ensuring created principals cannot exceed the permissions defined in the admin policy.
func IamResourceWildcards ¶
IamResourceWildcards returns the IAM resource wildcards
func KmsKeyExists ¶
func S3ResourceAccountCondition ¶
S3ResourceAccountCondition returns the condition for S3 resource account
func SsmSendCommand ¶
Types ¶
type Action ¶
type Action struct {
Action string
SupportsResourceLimit bool // is the action able to be limited by the aws:ResourceAccount value of the request
SupportsManagedByCondition bool // is the action able to be limited by the aws:ResourceTag/posit.team/managed-by value of the request
}
func CloudwatchActions ¶
func CloudwatchActions() []Action
CloudwatchActions returns CloudWatch-related actions
func ComputeOptimizerActions ¶
func ComputeOptimizerActions() []Action
ComputeOptimizerActions returns Compute Optimizer-related actions
func DirectoryServiceActions ¶
func DirectoryServiceActions() []Action
DirectoryServiceActions returns Directory Service-related actions
func EventsActions ¶
func EventsActions() []Action
EventsActions returns EventBridge-related actions
func FirehoseActions ¶
func FirehoseActions() []Action
FirehoseActions returns Firehose-related actions
func IamWildcardActions ¶
func IamWildcardActions() []Action
IamWildcardActions returns IAM wildcard actions
func OrganizationActions ¶
func OrganizationActions() []Action
OrganizationActions returns AWS Organizations-related actions
func ResourceExplorerActions ¶
func ResourceExplorerActions() []Action
ResourceExplorerActions returns Resource Explorer-related actions
func SecretsManagerActions ¶
func SecretsManagerActions() []Action
SecretsManagerActions returns Secrets Manager-related actions
func (Action) MarshalYAML ¶
func (Action) RequiresRequestTagKeys ¶
func (Action) SupportsGlobalResourceCondition ¶
type Credentials ¶
type Credentials struct {
// contains filtered or unexported fields
}
func NewCredentials ¶
func NewCredentials(accountID string, profile string, customRoleArn string, externalID string) (c *Credentials)
func OnlyAwsCredentials ¶
func OnlyAwsCredentials(c types.Credentials) (*Credentials, error)
func (*Credentials) AccountID ¶
func (c *Credentials) AccountID() string
func (*Credentials) EnvVars ¶
func (c *Credentials) EnvVars() map[string]string
func (*Credentials) Expired ¶
func (c *Credentials) Expired() bool
func (*Credentials) Identity ¶
func (c *Credentials) Identity() string
type ManagedPolicy ¶
type ManagedPolicy struct {
ManagedPolicyName string `yaml:"ManagedPolicyName"`
PolicyDocument PolicyDocument `yaml:"PolicyDocument"`
}
type Policy ¶
type Policy struct {
PolicyName string `yaml:"PolicyName"`
PolicyDocument PolicyDocument `yaml:"PolicyDocument"`
}
type PolicyDocument ¶
type PolicyDocument struct {
Version string `yaml:"Version"`
Statement []PolicyStatement `yaml:"Statement"`
}
func BuildCompleteAdminPolicyDocument ¶
func BuildCompleteAdminPolicyDocument() PolicyDocument
BuildCompleteAdminPolicyDocument constructs the complete PositTeamDedicatedAdmin IAM policy document. This policy contains all AWS service actions needed for PTD operations, including:
- Self-constraining statements (permissions boundary enforcement)
- IAM, S3, ECR, EKS, EC2, and other AWS service permissions
- Resource account and tag-based conditions to limit scope
The policy is used both as a permissions boundary and as an attached managed policy for PTD-created IAM roles to ensure they cannot escalate beyond PTD's allowed permissions.
Returns a PolicyDocument that can be marshaled to JSON for AWS IAM API calls or YAML for CloudFormation templates.
func NewAdminPolicyDocument ¶
func NewAdminPolicyDocument() PolicyDocument
func (*PolicyDocument) AddActions ¶
func (pd *PolicyDocument) AddActions(actions []Action)
func (*PolicyDocument) AddStatements ¶
func (pd *PolicyDocument) AddStatements(statements []PolicyStatement)
func (*PolicyDocument) GetStatementBySid ¶
func (pd *PolicyDocument) GetStatementBySid(sid string) *PolicyStatement
func (PolicyDocument) SubstituteCloudFormationRefs ¶
func (pd PolicyDocument) SubstituteCloudFormationRefs(accountID string) PolicyDocument
SubstituteCloudFormationRefs returns a new PolicyDocument with CloudFormation intrinsic function references replaced with actual values. This is needed when using the policy with direct IAM API calls (not CloudFormation).
Substitutions performed:
- "AWS::AccountId" -> accountID (from !Ref AWS::AccountId)
- "${AWS::AccountId}" -> accountID (from !Sub templates)
type PolicyStatement ¶
type PolicyStatement struct {
Effect string `yaml:"Effect"`
Action []string `yaml:"Action"`
Sid string `yaml:"Sid,omitempty"`
Principal Principal `yaml:"Principal,omitempty" json:"Principal,omitempty"`
Resource []yaml.Node `yaml:"Resource,omitempty" json:"Resource,omitempty"`
Condition yaml.Node `yaml:"Condition,omitempty" json:"Condition,omitempty"`
}
PolicyStatement defines a statement in a policy document.
func EcrAwsAccountStatements ¶
func EcrAwsAccountStatements() []PolicyStatement
EcrAwsAccountStatements returns ECR cross-account policy statements
func IamStatements ¶
func IamStatements() []PolicyStatement
IamStatements returns IAM-related policy statements
func S3Statements ¶
func S3Statements() []PolicyStatement
S3Statements returns S3-related policy statements
func SelfConstrainingStatements ¶
func SelfConstrainingStatements() []PolicyStatement
SelfConstrainingStatements returns self-constraining policy statements
func (*PolicyStatement) AddAction ¶
func (ps *PolicyStatement) AddAction(a string)
func (PolicyStatement) MarshalJSON ¶
func (ps PolicyStatement) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for PolicyStatement. This converts yaml.Node fields (Resource, Condition) to simple types for the IAM API, while still preserving yaml.Node for YAML/CloudFormation template generation.
type ProxySession ¶
type ProxySession struct {
// contains filtered or unexported fields
}
func NewProxySession ¶
func NewProxySession(t Target, awsCliPath string, localPort string, file string) *ProxySession
func (*ProxySession) Preflight ¶
func (p *ProxySession) Preflight() (active bool, err error)
func (*ProxySession) Stop ¶
func (p *ProxySession) Stop() error
func (*ProxySession) Wait ¶
func (p *ProxySession) Wait()
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func (Registry) GetAuthForCredentials ¶
func (r Registry) GetAuthForCredentials(ctx context.Context, c types.Credentials) (username string, password string, err error)
GetAuthForCredentials is deprecated - ECR is no longer used. Images are now pulled from public Docker Hub.
func (Registry) GetLatestDigestForRepository ¶
func (r Registry) GetLatestDigestForRepository(ctx context.Context, c types.Credentials, repository string) (string, error)
GetLatestDigestForRepository is deprecated - ECR is no longer used. Images are now pulled from public Docker Hub.
func (Registry) GetLatestImageForRepository ¶
func (r Registry) GetLatestImageForRepository(ctx context.Context, c types.Credentials, repository string) (details types.ImageDetails, err error)
GetLatestImageForRepository is deprecated - ECR is no longer used. Images are now pulled from public Docker Hub.
func (Registry) RegistryURI ¶
type Role ¶
type Role struct {
RoleName string `yaml:"RoleName"`
ManagedPolicyArns []PolicyRef `yaml:"ManagedPolicyArns"`
RolePolicyList []Policy `yaml:"Policies"`
AssumeRolePolicyDocument PolicyDocument `yaml:"AssumeRolePolicyDocument"`
PermissionsBoundary PolicyRef `yaml:"PermissionsBoundary,omitempty"`
Path string `yaml:"Path"`
Tags []map[string]string `yaml:"Tags"`
}
type SecretStore ¶
type SecretStore struct {
// contains filtered or unexported fields
}
func NewSecretStore ¶
func NewSecretStore(region string) *SecretStore
func (*SecretStore) CreateSecret ¶
func (s *SecretStore) CreateSecret(ctx context.Context, c types.Credentials, secretName string, secretString string) error
func (*SecretStore) CreateSecretIfNotExists ¶
func (s *SecretStore) CreateSecretIfNotExists(ctx context.Context, c types.Credentials, secretName string, secret any) (err error)
func (*SecretStore) EnsureWorkloadSecret ¶
func (s *SecretStore) EnsureWorkloadSecret(ctx context.Context, c types.Credentials, workloadName string, secret any) (err error)
func (*SecretStore) GetSecretValue ¶
func (s *SecretStore) GetSecretValue(ctx context.Context, c types.Credentials, secretName string) (string, error)
func (*SecretStore) PutSecretValue ¶
func (s *SecretStore) PutSecretValue(ctx context.Context, c types.Credentials, secretName string, secretString string) error
func (*SecretStore) SecretExists ¶
func (s *SecretStore) SecretExists(ctx context.Context, c types.Credentials, secretName string) bool
type Target ¶
type Target struct {
// clusters is currently only relevant/supported for aws.
Clusters map[string]types.AWSWorkloadClusterConfig
// contains filtered or unexported fields
}
func (Target) CloudProvider ¶
func (t Target) CloudProvider() types.CloudProvider
func (Target) ControlRoom ¶
func (Target) CreateAdminPolicyAsResource ¶
func (Target) Credentials ¶
func (Target) HashName ¶
HashName returns an obfuscated name for the target that can be used as a unique identifier.
func (Target) PulumiBackendUrl ¶
func (Target) PulumiSecretsProviderKey ¶
func (Target) SecretStore ¶
func (t Target) SecretStore() types.SecretStore
func (Target) StateBucketName ¶
func (Target) TailscaleEnabled ¶
func (Target) Type ¶
func (t Target) Type() types.TargetType