Documentation ¶
Index ¶
- Constants
- Variables
- func IsNoUpdateError(err error) bool
- func IsNotFoundError(err error) bool
- type AWSECRRepository
- type AWSECRRepository_LifecyclePolicy
- type AWSElastiCacheReplicationGroup
- type AWSIAMPolicy
- type AWSIAMRole
- type AWSRDSDBCluster
- type AWSRDSDBClusterParameterGroup
- type AWSRDSDBInstance
- type AWSRDSDBParameterGroup
- type AWSS3Bucket
- type AWSSQSQueue
- type AWSSecretsManagerSecret
- type AWSSecretsManagerSecretTargetAttachment
- type AssumeRolePolicyDocument
- type AssumeRolePolicyStatement
- type Client
- type Controller
- type CreateStackInput
- type DeleteStackInput
- type DescribeStackEventsInput
- type DescribeStacksInput
- type DescribeStacksOutput
- type ECRLifecyclePolicy
- type ECRLifecyclePolicyAction
- type ECRLifecyclePolicyRule
- type ECRLifecyclePolicySelection
- type GenerateSecretString
- type GetSecretValueInput
- type Output
- type Outputs
- type Parameter
- type PolicyCondition
- type PolicyDocument
- type PolicyPrincipal
- type PolicyStatement
- type ServiceAccountCreator
- type ServiceEntryCreator
- type Stack
- type StackObjectEmptier
- type StackOutputWhitelister
- type StackPolicyAttacher
- type StackPolicyProvider
- type StackSecretContributor
- type StackSecretOutputter
- type State
- type StateEvent
- type Tag
- type Template
- type UpdateStackInput
Constants ¶
const ( // Finalizer is assigned to objects that have cloudformation state Finalizer = "cloudformatiton.finalizers.govsvc.uk" // AccessGroupLabel is a label used reference a target IAM role for StackPolicyAttacher AccessGroupLabel = "group.access.govsvc.uk" )
const ( ECRLifecycleMoreThan = "imageCountMoreThan" ECRLifecyclePolicyExpire = "expire" )
const CreateComplete = cloudformation.StackStatusCreateComplete
const CreateFailed = cloudformation.StackStatusCreateFailed
const CreateInProgress = cloudformation.StackStatusCreateInProgress
const DeleteComplete = cloudformation.StackStatusDeleteComplete
const DeleteFailed = cloudformation.StackStatusDeleteFailed
const DeleteInProgress = cloudformation.StackStatusDeleteInProgress
const ReviewInProgress = cloudformation.StackStatusReviewInProgress
const RollbackComplete = cloudformation.StackStatusRollbackComplete
const RollbackFailed = cloudformation.StackStatusRollbackFailed
const RollbackInProgress = cloudformation.StackStatusRollbackInProgress
const UpdateComplete = cloudformation.StackStatusUpdateComplete
const UpdateInProgress = cloudformation.StackStatusUpdateInProgress
const UpdateRollbackComplete = cloudformation.StackStatusUpdateRollbackComplete
const UpdateRollbackCompleteCleanupInProgress = cloudformation.StackStatusUpdateRollbackCompleteCleanupInProgress
const UpdateRollbackFailed = cloudformation.StackStatusUpdateRollbackFailed
const UpdateRollbackInProgress = cloudformation.StackStatusRollbackInProgress
Variables ¶
var ( // ErrStackNotFound returned when stack does not exist, or has been deleted ErrStackNotFound = fmt.Errorf("STACK_NOT_FOUND") // NoUpdatesErrMatch is string to match in error from aws to detect if nothing to update NoUpdatesErrMatch = "No updates" // NoExistErrMatch is a string to match if stack does not exist NoExistErrMatch = "does not exist" )
var ( // DefaultReconcileDeadline is the default timeout for reconcile // context. DeadlineExceeded errors will be retried later. DefaultReconcileDeadline = time.Minute * 1 // DefaultRequeueTimeout is the default time when a reconcile needs // requeuing after deadline is hit DefaultRequeueTimeout = time.Second * 10 // DefaultPollingInterval is the frequency that cloudformation client // polls for state changes DefaultPollingInterval = time.Second * 20 // DefaultReconcileSuccessRetryDelay is the default delay after a successful // Reconcile that Reconcile will be called again if RequeueOnSuccess is true DefaultReconcileSuccessRetryDelay = time.Hour * 1 // ErrPrincipalNotFound is returned if no Principal (role record) can // be found to attach a policy to ErrPrincipalNotFound = fmt.Errorf("PRINCIPAL_NOT_FOUND") // ErrPrincipalNotReady is returned when a principal has not been fully // provisioned yet. ErrPrincipalNotReady = fmt.Errorf("PRINCIPAL_NOT_READY") // ErrPrincipalMultipleMatches is returned if a label selector matches // multiple principals, which is not currently supported ErrPrincipalMultipleMatches = fmt.Errorf("PRINCIPAL_MULTIPLE_MATCHES") // ErrMissingKind returned on config error ErrMissingKind = fmt.Errorf("MISSING_CONTROLLER_RESOURCE_KIND") // ErrMissingPrincipalKind returned on config error ErrMissingPrincipalKind = fmt.Errorf("MISSING_CONTROLLER_PRINCIPAL_KIND") // ErrMissingCloudformationClient returned if no cloudformation client setup ErrMissingCloudformationClient = fmt.Errorf("MISSING_CLOUDFORMATION_CLIENT") // ErrMissingAWSClient return on config error ErrMissingAWSClient = fmt.Errorf("MISSING_AWS_CLIENT") )
var GetAtt = goformation.GetAtt
var Join = goformation.Join
var NewTemplate = goformation.NewTemplate
var Ref = goformation.Ref
var Sub = goformation.Sub
Functions ¶
func IsNoUpdateError ¶
func IsNotFoundError ¶
Types ¶
type AWSECRRepository ¶
type AWSECRRepository = goformationecr.Repository
type AWSECRRepository_LifecyclePolicy ¶
type AWSECRRepository_LifecyclePolicy = goformationecr.Repository_LifecyclePolicy
type AWSElastiCacheReplicationGroup ¶
type AWSElastiCacheReplicationGroup = goformationelasticache.ReplicationGroup
type AWSIAMPolicy ¶
type AWSIAMPolicy = goformationiam.Policy
type AWSIAMRole ¶
type AWSIAMRole = goformationiam.Role
type AWSRDSDBCluster ¶
type AWSRDSDBCluster = goformationrds.DBCluster
type AWSRDSDBClusterParameterGroup ¶
type AWSRDSDBClusterParameterGroup = goformationrds.DBClusterParameterGroup
type AWSRDSDBInstance ¶
type AWSRDSDBInstance = goformationrds.DBInstance
type AWSRDSDBParameterGroup ¶
type AWSRDSDBParameterGroup = goformationrds.DBParameterGroup
type AWSS3Bucket ¶
type AWSS3Bucket = goformations3.Bucket
type AWSSQSQueue ¶
type AWSSQSQueue = goformationsqs.Queue
type AWSSecretsManagerSecret ¶
type AWSSecretsManagerSecret = goformationsecretsmanager.Secret
type AWSSecretsManagerSecretTargetAttachment ¶
type AWSSecretsManagerSecretTargetAttachment = goformationsecretsmanager.SecretTargetAttachment
type AssumeRolePolicyDocument ¶
type AssumeRolePolicyDocument struct { Version string Statement []AssumeRolePolicyStatement }
func NewAssumeRolePolicyDocument ¶
func NewAssumeRolePolicyDocument(serviceOperatorRoleArn string) AssumeRolePolicyDocument
func NewAssumeRolePolicyDocumentWithServiceAccount ¶
func NewAssumeRolePolicyDocumentWithServiceAccount(serviceOperatorRoleArn string, federatedPrincipal string, federatedConditionKey string, federatedConditionValue string) AssumeRolePolicyDocument
type AssumeRolePolicyStatement ¶
type AssumeRolePolicyStatement struct { Effect string Principal PolicyPrincipal Action []string Condition PolicyCondition `json:"Condition,omitempty"` }
type Client ¶
type Client struct { // ClusterName is used to prefix any generated names to avoid clashes ClusterName string // Client is the AWS SDK Client implementation to use Client sdk.Client // PollingInterval is the duration between calls to check state when waiting for apply/destroy to complete PollingInterval time.Duration }
Client performs cloudformation operations on objects that implement the Stack interface
func (*Client) Apply ¶
Apply reconciles the state of the remote cloudformation stack and blocks until the stack is no longer in an creating/applying state or a ctx timeout is hit Calls should be retried if DeadlineExceeded errors are hit Returns any outputs on successful apply. Will update stack with current status
type Controller ¶
type Controller struct { Scheme *runtime.Scheme // Scheme is required for operations like gc Log logr.Logger // Log will be used to report each reconcile KubernetesClient client.Client // KubernetesClient is required to talk to api CloudFormationClient *Client // CloudFormationClient is required to talk to aws Parameters []*Parameter // Parameters are default params always passed to Apply Kind Stack // Kind is the kubernetes resource type to reconcile PrincipalListKind object.PrincipalLister // PrincipalListKind is the type that will be used to lookup role data for StackPolicyAttacher ReconcileTimeout time.Duration // ReconcileTimeout is the max execution time on Reconcile before requeuing ReconcileTimeoutRetryDelay time.Duration // ReconcileTimeoutRetryDelay is the delay before trying again after ReconcileTimeout is hit ReconcileErrorRetryDelay time.Duration // ReconcileErrorRetryDelay is the delay before trying again after Reconcile returns an error RequeueOnSuccess bool // RequeueOnSuccess is a flag indicating whether to requeue a successful Reconcile request ReconcileSuccessRetryDelay time.Duration // ReconcileSuccessRetryDelay is the delay before re-executing Reconcile on success }
Controller implements kubernetes controller-runtime reconcile.Reconciler to reconcile a kubernetes resource type that implements the Stack interface using cloudformation.
It should be initialised with the Kind that it will reconcile (ie v1beta1.Postgres{}) any parameters that should always be passed to cloudformation during reconciliation. Setting parameters here is useful for variables that are based on the environment rather than the resource options, for example which region or vpc to deploy to may not be something you wish to make configurable via the resource, but rather globally on the manager
TODO: add example
func (*Controller) Reconcile ¶
Reconcile synchronises state between the resource and a cloudformation stack
func (*Controller) SetupWithManager ¶
func (r *Controller) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager validates and registers this controller with the manager and api
type CreateStackInput ¶
type CreateStackInput = cloudformation.CreateStackInput
type DeleteStackInput ¶
type DeleteStackInput = cloudformation.DeleteStackInput
type DescribeStackEventsInput ¶
type DescribeStackEventsInput = cloudformation.DescribeStackEventsInput
type DescribeStacksInput ¶
type DescribeStacksInput = cloudformation.DescribeStacksInput
type DescribeStacksOutput ¶
type DescribeStacksOutput = cloudformation.DescribeStacksOutput
type ECRLifecyclePolicy ¶
type ECRLifecyclePolicy struct {
Rules []ECRLifecyclePolicyRule `json:"rules,omitempty"`
}
type ECRLifecyclePolicyAction ¶
type ECRLifecyclePolicyAction struct {
Type string `json:"type,omitempty"`
}
type ECRLifecyclePolicyRule ¶
type ECRLifecyclePolicyRule struct { RulePriority int64 `json:"rulePriority"` Description string `json:"description,omitempty"` Selection ECRLifecyclePolicySelection `json:"selection,omitempty"` Action ECRLifecyclePolicyAction `json:"action,omitempty"` }
type GenerateSecretString ¶
type GenerateSecretString = goformationsecretsmanager.Secret_GenerateSecretString
type GetSecretValueInput ¶
type GetSecretValueInput = secretsmanager.GetSecretValueInput
type Output ¶
type Output = cloudformation.Output
type Parameter ¶
type Parameter = cloudformation.Parameter
type PolicyCondition ¶
type PolicyDocument ¶
type PolicyDocument struct { Version string Statement []PolicyStatement }
func NewRolePolicyDocument ¶
func NewRolePolicyDocument(resources, actions []string) PolicyDocument
type PolicyPrincipal ¶
type PolicyStatement ¶
type ServiceAccountCreator ¶
type ServiceAccountCreator interface { Stack GetServiceAccountName() string GetServiceAccountAnnotations(outputs Outputs) map[string]string }
ServiceAccountCreator names a ServiceAccount to be used to access created resources
type ServiceEntryCreator ¶
type ServiceEntryCreator interface { Stack GetServiceEntryName() string GetServiceEntrySpecs(outputs Outputs) ([]map[string]interface{}, error) }
ServiceEntryCreator names a ServiceEntry to hold what are essentially egress firewall rules.
type Stack ¶
Stack represents a type that can marshall itself to a cloudformation config for use with Client
type StackObjectEmptier ¶
type StackOutputWhitelister ¶
type StackOutputWhitelister interface {
GetStackOutputWhitelist() []string
}
StackOutputWhitelister allows a type to return a list of Output keys whose values are safe to be displayed in the Status of the resource. This is useful for when you want to display some outputs without having them embedded into a Secret
type StackPolicyAttacher ¶
type StackPolicyAttacher interface { Stack GetStackRoleParameters(role string) ([]*Parameter, error) }
StackPolicyAttacher adds an additional method to Stack for injecting a target role name into stack parameters that will be the receiver of policies provisioned by this stack. Role parameters are added at both Update and Create time. The role provided will already exist and may contain other existing policies which should not be altered.
type StackPolicyProvider ¶
type StackPolicyProvider interface {
GetStackPolicy() aws.StackPolicyDocument
}
StackPolicyProvider allows a type to return a string representation of a CloudFormationStack policy to prevent unauthorised operations on a given stack.
type StackSecretContributor ¶
type StackSecretOutputter ¶
type StackSecretOutputter interface { Stack object.SecretNamer }
StackSecretOutputter allows a type to return the name of a kubernetes Secret that will be populated with any cloudformation outputs. This is useful when the cloudformation stack returns sensitive information that must be consumed as configuration, for example a username, password and connection string for a database.
type State ¶
type State = cloudformation.Stack
Alias types from the various cloudformation packages so we can access relevant parts via this package for convenience
type StateEvent ¶
type StateEvent = cloudformation.StackEvent
type Tag ¶
type Tag = goformationtags.Tag
type Template ¶
type Template = goformation.Template
type UpdateStackInput ¶
type UpdateStackInput = cloudformation.UpdateStackInput