Documentation ¶
Index ¶
- Constants
- Variables
- func BackupDetailsToString(b *ddbTypes.BackupDetails) string
- func BackupStatus(ctx context.Context, backupARN string) (*ddbTypes.BackupDescription, error)
- func CLIPrompt(f *gconfig.Field) error
- func CleanName(name string) string
- func DeployProductionFrontend(ctx context.Context, cfg config.FrontendDeployerConfig) error
- func PublishManifest(ctx context.Context, releaseBucket, version string) error
- func RenderLocalFrontendConfig(rfc RenderFrontendConfig) (string, error)
- func RenderProductionFrontendConfig(rfc RenderFrontendConfig) (string, error)
- func RestoreStatus(ctx context.Context, targetTableName string) (*ddbTypes.TableDescription, error)
- func RestoreSummaryToString(r *ddbTypes.RestoreSummary) string
- func RunConfigTest(ctx context.Context, testable interface{}) error
- func SetConfigInContext(ctx context.Context, cfg Config) context.Context
- func StackExists(ctx context.Context, stackName string) (bool, error)
- func StartBackup(ctx context.Context, tableName string, backupName string) (*ddbTypes.BackupDetails, error)
- func StartRestore(ctx context.Context, backupARN string, targetTableName string) (*ddbTypes.TableDescription, error)
- func TryGetCurrentAccountID(ctx context.Context) (string, error)
- type Config
- func (c Config) CDKContextArgs() []string
- func (c *Config) CfnParams() ([]types.Parameter, error)
- func (c *Config) CfnTemplateURL() string
- func (c *Config) DeployCloudFormation(ctx context.Context, confirm bool) (string, error)
- func (c Config) GetDevStageName() (string, error)
- func (c *Config) GetStackStatus(ctx context.Context) (types.StackStatus, error)
- func (c *Config) LoadOutput(ctx context.Context) (Output, error)
- func (c *Config) ResetIdentityProviderToCognito(filepath string) error
- func (c *Config) Save(f string) error
- func (c *Config) SetDNSRecord(ctx context.Context) error
- type DeployConfigReader
- type Deployment
- type EnvDeploymentConfig
- type FeatureMap
- type Manifest
- type Notifications
- type Output
- type Parameters
- type Provider
- type ProviderMap
- type ProviderWriter
- type Release
- type RemoteDeploymentConfig
- type RenderFrontendConfig
Constants ¶
const DefaultCommonFateAdministratorsGroup = "common_fate_administrators"
const DefaultFilename = "deployment.yml"
const DeprecatedDefaultFilename = "granted-deployment.yml"
Variables ¶
var AvailableRegions = []string{
"ap-southeast-2",
"us-west-2",
"us-east-1",
"eu-central-1",
}
AvailableRegions are the regions that we currently release CloudFormation templates to.
var DeploymentConfigContextKey contextkey
var DeprecatedDefaultFilenameWarning = clierr.Warn("Since v0.11.0 the default deployment config file has been renamed from 'granted-deployment.yml' to 'deployment.yml'. To update, rename the file now or run this command to rename via the cli `mv granted-deployment.yml deployment.yml`")
var ErrConfigNotExist = errors.New("config does not exist")
var ErrConfigNotNotSetInContext = errors.New("config has not been set in context")
var ErrFeatureNotDefined = errors.New("feature is not defined")
Functions ¶
func BackupDetailsToString ¶
func BackupDetailsToString(b *ddbTypes.BackupDetails) string
func BackupStatus ¶
func CLIPrompt ¶
CLIPrompt prompts the user to enter a value for the config varsiable in a CLI context. If the config variable implements Defaulter, the default value is returned and the user is not prompted for any input.
func CleanName ¶
CleanName will replace all non letter characters from the string with "-"
when creating labels from git branch names, they may contain slashes etc which are incompatible
See the DynamoDB table naming guide: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html
It panics if the regex cannot be parsed.
func DeployProductionFrontend ¶
func DeployProductionFrontend(ctx context.Context, cfg config.FrontendDeployerConfig) error
func PublishManifest ¶
PublishManifest updates the manifest.json file in the release bucket.
func RenderLocalFrontendConfig ¶
func RenderLocalFrontendConfig(rfc RenderFrontendConfig) (string, error)
RenderLocalFrontendConfig renders the aws-exports.js file to be used in local development. This accepts a specific config so this function can be reused easily
func RenderProductionFrontendConfig ¶
func RenderProductionFrontendConfig(rfc RenderFrontendConfig) (string, error)
RenderProductionFrontendConfig renders the aws-exports.json file to be used in a production deployment of the frontend to AWS S3 This accepts a specific config so this function can be reused easily in a custom resource lamda
func RestoreStatus ¶
func RestoreSummaryToString ¶
func RestoreSummaryToString(r *ddbTypes.RestoreSummary) string
func RunConfigTest ¶
RunConfigTest runs ConfigTest() if it is implemented on the interface
func StartBackup ¶
func StartRestore ¶
Types ¶
type Config ¶
type Config struct { Version int `yaml:"version"` Deployment Deployment `yaml:"deployment"` // contains filtered or unexported fields }
func LoadConfig ¶
LoadConfig attempts to load the config file at path f if it does not exist, returns ErrConfigNotExist else returns the config or any other error
in CLI commands, it is preferable to use deploy.ConfigFromContext(ctx) where gdeploy.RequireDeploymentConfig has run as a before function for the command gdeploy.RequireDeploymentConfig will return a helpful cli error if there are any issues
func NewStagingConfig ¶
NewStagingConfig sets up a Config for staging deployments. These deployments currently still use the CDK rather than CloudFormation.
func SetupDevConfig ¶
SetupDevConfig sets up the config for local development.
func SetupReleaseConfig ¶
SetupReleaseConfig sets up the release configuration used in production deployments.
func (Config) CDKContextArgs ¶
CDKContextArgs returns the CDK context arguments in the form "-c" "ArgName=ArgValue"
This should only be used in development, where the StackName variable is always of the form "common-fate-$STAGE". It panics if this is not the case.
func (*Config) CfnParams ¶
CfnParams converts the parameters to types supported by CloudFormation deployments.
func (*Config) CfnTemplateURL ¶
CfnTemplateURL returns the CloudFormation template URL. If the deployment release points to an S3 object (https://custom-bucket.s3.amazonaws.com/path/to/template.json) It is turned into a HTTPS URL. If a regular version number (v0.1.0) is used, we point to our official release bucket.
func (*Config) DeployCloudFormation ¶
DeployCloudFormation creates a CloudFormation stack based on the config
func (Config) GetDevStageName ¶
GetDevStageName returns the stage name to be used in a CDK deployment. It expects that the stack name is in the form "common-fate--$STAGE".
func (*Config) GetStackStatus ¶
GetStackStatus indicates whether the Cloud Formation stack is online (via "CREATE_COMPLETE")
func (*Config) LoadOutput ¶
LoadOutput loads the outputs for the current deployment.
func (*Config) ResetIdentityProviderToCognito ¶
Reset Identity Provider to cognito settings
type DeployConfigReader ¶
type DeployConfigReader interface { ReadProviders(ctx context.Context) (ProviderMap, error) ReadNotifications(ctx context.Context) (*Notifications, error) }
DeployConfigReader reads configuration about this Common Fate deployment, including provider and notification information.
func GetDeploymentConfig ¶
func GetDeploymentConfig() (DeployConfigReader, error)
type Deployment ¶
type Deployment struct { StackName string `yaml:"stackName"` Account string `yaml:"account"` Region string `yaml:"region"` // Release may be one of two formats: // // 1. A release version tag (e.g. 'v0.1.0'). This uses a release // from Common Fate's release bucket. // // 2. A path to a CloudFormation template in S3, in the format // 'https://custom-bucket.s3.amazonaws.com/path/to/template.json'. // Note that the S3 bucket must be in the same region as the 'Region' parameter. Release string `yaml:"release"` // Dev is set to true for internal development deployments only. Dev *bool `yaml:"dev,omitempty"` Parameters Parameters `yaml:"parameters"` Tags map[string]string `yaml:"tags,omitempty"` }
type EnvDeploymentConfig ¶
type EnvDeploymentConfig struct{}
EnvDeploymentConfig reads config values from environment variables.
func (*EnvDeploymentConfig) ReadNotifications ¶
func (el *EnvDeploymentConfig) ReadNotifications(ctx context.Context) (*Notifications, error)
func (*EnvDeploymentConfig) ReadProviders ¶
func (el *EnvDeploymentConfig) ReadProviders(ctx context.Context) (ProviderMap, error)
type FeatureMap ¶
Feature map represents the type used for features like identity and notifications
func UnmarshalFeatureMap ¶
func UnmarshalFeatureMap(data string) (FeatureMap, error)
UnmarshalFeatureMap parses the JSON configuration data and returns an initialised FeatureMap. If `data` is an empty string an empty FeatureMap is returned.
func (FeatureMap) Remove ¶
func (f FeatureMap) Remove(id string)
Remove the feature in the map, if the map is not initialised, it does nothing
type Manifest ¶
type Notifications ¶
type Notifications struct { Slack map[string]string `yaml:"slack,omitempty" json:"slack,omitempty"` SlackIncomingWebhooks FeatureMap `yaml:"slackIncomingWebhooks,omitempty" json:"slackIncomingWebhooks,omitempty"` }
func UnmarshalNotifications ¶
func UnmarshalNotifications(data string) (*Notifications, error)
UnmarshalNotifications parses the JSON configuration data and returns an initialised Notifications. If `data` is an empty string an empty Notifications is returned.
type Output ¶
type Output struct { CognitoClientID string `json:"CognitoClientID"` SAMLIdentityProviderName string `json:"SAMLIdentityProviderName"` CloudFrontDomain string `json:"CloudFrontDomain"` FrontendDomainOutput string `json:"FrontendDomainOutput"` CloudFrontDistributionID string `json:"CloudFrontDistributionID"` S3BucketName string `json:"S3BucketName"` UserPoolID string `json:"UserPoolID"` UserPoolDomain string `json:"UserPoolDomain"` APIURL string `json:"APIURL"` WebhookURL string `json:"WebhookURL"` GovernanceURL string `json:"GovernanceURL"` WebhookLogGroupName string `json:"WebhookLogGroupName"` APILogGroupName string `json:"APILogGroupName"` IDPSyncLogGroupName string `json:"IDPSyncLogGroupName"` AccessHandlerLogGroupName string `json:"AccessHandlerLogGroupName"` EventBusLogGroupName string `json:"EventBusLogGroupName"` EventsHandlerLogGroupName string `json:"EventsHandlerLogGroupName"` GranterLogGroupName string `json:"GranterLogGroupName"` SlackNotifierLogGroupName string `json:"SlackNotifierLogGroupName"` DynamoDBTable string `json:"DynamoDBTable"` GranterStateMachineArn string `json:"GranterStateMachineArn"` EventBusArn string `json:"EventBusArn"` EventBusSource string `json:"EventBusSource"` IdpSyncFunctionName string `json:"IdpSyncFunctionName"` Region string `json:"Region"` PaginationKMSKeyARN string `json:"PaginationKMSKeyARN"` AccessHandlerExecutionRoleARN string `json:"AccessHandlerExecutionRoleARN"` CacheSyncLogGroupName string `json:"CacheSyncLogGroupName"` RestAPIExecutionRoleARN string `json:"RestAPIExecutionRoleARN"` IDPSyncExecutionRoleARN string `json:"IDPSyncExecutionRoleARN"` CacheSyncFunctionName string `json:"CacheSyncFunctionName"` CLIAppClientID string `json:"CLIAppClientID"` }
Output is the output from deploying the CDK stack to AWS.
func (Output) DeployFrontend ¶
DeployFrontend uploads the frontend to S3 and invalidates CloudFront
func (Output) FrontendURL ¶
func (Output) PrintSAMLTable ¶
func (o Output) PrintSAMLTable()
func (Output) PrintTable ¶
func (c Output) PrintTable()
func (Output) ToRenderFrontendConfig ¶
func (o Output) ToRenderFrontendConfig() RenderFrontendConfig
type Parameters ¶
type Parameters struct { CognitoDomainPrefix string `yaml:"CognitoDomainPrefix"` AdministratorGroupID string `yaml:"AdministratorGroupID"` DeploymentSuffix string `yaml:"DeploymentSuffix,omitempty"` IdentityProviderType string `yaml:"IdentityProviderType,omitempty"` SamlSSOMetadata string `yaml:"SamlSSOMetadata,omitempty"` SamlSSOMetadataURL string `yaml:"SamlSSOMetadataURL,omitempty"` FrontendDomain string `yaml:"FrontendDomain,omitempty"` FrontendCertificateARN string `yaml:"FrontendCertificateARN,omitempty"` CloudfrontWAFACLARN string `yaml:"CloudfrontWAFACLARN,omitempty"` APIGatewayWAFACLARN string `yaml:"APIGatewayWAFACLARN,omitempty"` ExperimentalRemoteConfigURL string `yaml:"ExperimentalRemoteConfigURL,omitempty"` ExperimentalRemoteConfigHeaders string `yaml:"ExperimentalRemoteConfigHeaders,omitempty"` ProviderConfiguration ProviderMap `yaml:"ProviderConfiguration,omitempty"` IdentityConfiguration FeatureMap `yaml:"IdentityConfiguration,omitempty"` NotificationsConfiguration *Notifications `yaml:"NotificationsConfiguration,omitempty"` AnalyticsDisabled string `yaml:"AnalyticsDisabled,omitempty"` AnalyticsURL string `yaml:"AnalyticsURL,omitempty"` AnalyticsLogLevel string `yaml:"AnalyticsLogLevel,omitempty"` AnalyticsDeploymentStage string `yaml:"AnalyticsDeploymentStage,omitempty"` IdentityGroupFilter string `yaml:"IdentityGroupFilter,omitempty"` IDPSyncTimeoutSeconds string `yaml:"IDPSyncTimeoutSeconds,omitempty"` IDPSyncSchedule string `yaml:"IDPSyncSchedule,omitempty"` IDPSyncMemory string `yaml:"IDPSyncMemory,omitempty"` }
type ProviderMap ¶
func UnmarshalProviderMap ¶
func UnmarshalProviderMap(data string) (ProviderMap, error)
UnmarshalProviderMap parses the JSON configuration data and returns an initialised struct. If `data` is an empty string an empty IdentityConfig{} object is returned.
func (*ProviderMap) Add ¶
func (f *ProviderMap) Add(id string, p Provider) error
Adds the Provider if it does not exist
func (ProviderMap) GetIDForNewProvider ¶
func (p ProviderMap) GetIDForNewProvider(defaultID string) string
GetIDForNewProvider returns an ID for a provider based on the following rules:
1. If the provider isn't used in the config, the default ID is returned (e.g. `aws-sso`). 2. If the provider exists in the config, a numbered suffix is added to the default ID (e.g. `aws-sso-2`). The numbers start at 2 and increment until an available ID is found.
type ProviderWriter ¶
type ProviderWriter interface {
WriteProviders(ctx context.Context, pm ProviderMap) error
}
type Release ¶
func (Release) CDKContextArgs ¶
CDKContextArgs returns the CDK context arguments in the form "-c" "ArgName=ArgValue"
type RemoteDeploymentConfig ¶
type RemoteDeploymentConfig struct {
// contains filtered or unexported fields
}
RemoteDeploymentConfig reads config values from an API.
func NewRemoteDeploymentConfig ¶
func NewRemoteDeploymentConfig(url string, headersString string) (*RemoteDeploymentConfig, error)
NewRemoteDeploymentConfig sets up a deployment config loader which fetches deployment configuration from a remote API.
headers should be passed as a comma-separated string in the following format:
KEY=VALUE,KEY=VALUE
func (*RemoteDeploymentConfig) ReadNotifications ¶
func (r *RemoteDeploymentConfig) ReadNotifications(ctx context.Context) (*Notifications, error)
func (*RemoteDeploymentConfig) ReadProviders ¶
func (r *RemoteDeploymentConfig) ReadProviders(ctx context.Context) (ProviderMap, error)
func (*RemoteDeploymentConfig) WriteProviders ¶
func (r *RemoteDeploymentConfig) WriteProviders(ctx context.Context, pm ProviderMap) error