This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node { | |
def golangExists = fileExists '/home/ec2-user/go' | |
if (!golangExists) { | |
stage "Configure Go" | |
sh('curl -vs -L https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz -o /home/ec2-user/go.linux-amd64.tar.gz') | |
sh('tar -xzf /home/ec2-user/go.linux-amd64.tar.gz -C /home/ec2-user') | |
} else { | |
sh('echo Go installed') | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################ | |
# REFERENCES | |
# ConcourseCI Docs: https://concourse.ci | |
# Concourse tutorial: https://github.com/starkandwayne/concourse-tutorial | |
# | |
# NOTES | |
# This file is a self-contained description of a Concourse CI pipeline | |
# to deploy a http://gosparta.io application. There's a couple of things to | |
# note: | |
# - The YAML uses node references so that scripts can be defined in the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Custom command to startup a simple HelloWorld HTTP server | |
sqsWorkerCommand := &cobra.Command{ | |
Use: "sqsWorker", | |
Short: "Sample SQS Worker processor", | |
Long: fmt.Sprintf("Sample SQS listener"), | |
RunE: func(cmd *cobra.Command, args []string) error { | |
return sqsListener(sparta.OptionsGlobal.Logger) | |
}, | |
} | |
sparta.CommandLineOptions.Root.AddCommand(sqsWorkerCommand) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// And add the SSHKeyName option to the provision step | |
sparta.CommandLineOptions.Provision.Flags().StringVarP(&SSHKeyName, | |
"key", | |
"k", | |
"", | |
"SSH Key Name to use for EC2 instances") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SpartaPostBuildDockerImageHook workflow hook to build the Docker image | |
func SpartaPostBuildDockerImageHook(context map[string]interface{}, | |
serviceName string, | |
S3Bucket string, | |
buildID string, | |
awsSession *session.Session, | |
noop bool, | |
logger *logrus.Logger) error { | |
dockerServiceName := strings.ToLower(serviceName) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Setup an IAM role that allows the lambda function to send a message | |
// to the queue. | |
iamPolicy := sparta.IAMRoleDefinition{ | |
Privileges: []sparta.IAMRolePrivilege{ | |
sparta.IAMRolePrivilege{ | |
Actions: []string{ | |
"sqs:SendMessage"}, | |
Resource: gocf.GetAtt(sqsResourceName, "Arn").String(), | |
}, | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ec2IAMStatements = append(ec2IAMStatements, spartaIAM.PolicyStatement{ | |
Action: []string{"sqs:ChangeMessageVisibility", | |
"sqs:DeleteMessage", | |
"sqs:GetQueueAttributes", | |
"sqs:ReceiveMessage"}, | |
Effect: "Allow", | |
Resource: gocf.GetAtt(sqsResourceName, "Arn").String(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Environment: &gocf.EC2ContainerServiceTaskDefinitionContainerDefinitionsEnvironmentList{ | |
gocf.EC2ContainerServiceTaskDefinitionContainerDefinitionsEnvironment{ | |
Name: gocf.String("AWS_REGION"), | |
Value: gocf.Ref("AWS::Region").String(), | |
}, | |
gocf.EC2ContainerServiceTaskDefinitionContainerDefinitionsEnvironment{ | |
Name: gocf.String(sqsQueueURLEnvVar), | |
Value: gocf.Ref(sqsResourceName).String(), | |
}, | |
gocf.EC2ContainerServiceTaskDefinitionContainerDefinitionsEnvironment{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lambdaFn.Decorator = func(serviceName string, | |
lambdaResourceName string, | |
lambdaResource gocf.LambdaFunction, | |
resourceMetadata map[string]interface{}, | |
S3Bucket string, | |
S3Key string, | |
buildID string, | |
template *gocf.Template, | |
context map[string]interface{}, | |
logger *logrus.Logger) error { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Go get the outputs of the GrafanaStack | |
awsSession := session.New() | |
cloudFormationSvc := cloudformation.New(awsSession) | |
params := &cloudformation.DescribeStacksInput{ | |
StackName: aws.String(GrafanaStackName), | |
} | |
outputResults, outputResultsErr := cloudFormationSvc.DescribeStacks(params) |