Esempio n. 1
0
// Create new SQS Queue
func (svc *AmazonSQS) CreateQueue(in *SDK.CreateQueueInput) error {
	data, err := svc.client.CreateQueue(in)
	if err != nil {
		log.Error("[SQS] Error on `CreateQueue` operation, queue="+*in.QueueName, err)
		return err
	}
	log.Info("[SQS] Complete CreateQueue, queue="+*in.QueueName, *(data.QueueUrl))
	return nil
}
Esempio n. 2
0
// Create new DynamoDB table
func (d *AmazonDynamoDB) CreateTable(in *SDK.CreateTableInput) error {
	data, err := d.client.CreateTable(in)
	if err != nil {
		log.Error("[DynamoDB] Error on `CreateTable` operation, table="+*in.TableName, err)
		return err
	}
	log.Info("[DynamoDB] Complete CreateTable, table="+*in.TableName, data.TableDescription.TableStatus)
	return nil
}
Esempio n. 3
0
// get infomation of the table
func (d *AmazonDynamoDB) DescribeTable(name string) (*TableDescription, error) {
	req, err := d.client.DescribeTable(&SDK.DescribeTableInput{
		TableName: String(name),
	})
	if err != nil {
		log.Info("debug", err)
		return nil, err
	}
	return &TableDescription{req.Table}, nil
}
Esempio n. 4
0
// Delete DynamoDB table
func (d *AmazonDynamoDB) DeleteTable(name string) error {
	in := &SDK.DeleteTableInput{
		TableName: String(name),
	}
	data, err := d.client.DeleteTable(in)
	if err != nil {
		log.Error("[DynamoDB] Error on `DeleteTable` operation, table="+*in.TableName, err)
		return err
	}
	log.Info("[DynamoDB] Complete DeleteTable, table="+*in.TableName, data.TableDescription.TableStatus)
	return nil
}
Esempio n. 5
0
// Publish notification for arn(topic or endpoint)
func (svc *AmazonSNS) Publish(arn string, msg string, opt map[string]interface{}) error {
	msg = truncateMessage(msg)
	m := make(map[string]string)
	m["default"] = msg
	m["GCM"] = composeMessageGCM(msg, opt)
	m["APNS"] = composeMessageAPNS(msg, opt)
	m["APNS_SANDBOX"] = m["APNS"]
	jsonString, _ := json.Marshal(m)
	resp, err := svc.Client.Publish(&SDK.PublishInput{
		TargetArn:        String(arn),
		Message:          String(string(jsonString)),
		MessageStructure: String("json"),
	})
	if err != nil {
		log.Error("[SNS] error on `Publish` operation, arn="+arn, err.Error())
		return err
	}
	log.Info("[SNS] publish message", *resp.MessageId)
	return nil
}
Esempio n. 6
0
// Create new DynamoDB table
func (d *AmazonDynamoDB) CreateTable(ct *CreateTableInput) error {
	if ct.HashKey == nil {
		err := NewError("cannot find hashkey on CreateTableInput")
		return err
	}

	var keys []*SDK.KeySchemaElement
	keys = append(keys, ct.HashKey)
	if ct.HasRangeKey() {
		keys = append(keys, ct.RangeKey)
	}

	tableName := d.TablePrefix + ct.Name

	tp := NewProvisionedThroughput(ct.ReadCapacity, ct.WriteCapacity)
	in := &SDK.CreateTableInput{
		TableName:             String(tableName),
		KeySchema:             keys,
		AttributeDefinitions:  ct.AttributeList(),
		ProvisionedThroughput: tp,
	}

	if ct.HasLSI() {
		in.LocalSecondaryIndexes = ct.ListLSI()
	}
	if ct.HasGSI() {
		in.GlobalSecondaryIndexes = ct.ListGSI()
	}

	out, err := d.client.CreateTable(in)
	if err != nil {
		log.Error("[DynamoDB] Error on `CreateTable` operation, table="+tableName, err)
		return err
	}
	desc := TableDescription{out.TableDescription}
	log.Info("[DynamoDB] Complete CreateTable, table="+tableName, desc.GetTableStatus())
	return nil
}