GithubHelp home page GithubHelp logo

aws-sdk's Introduction

Amazon Web Services SDK for Salesforce Apex

Deploy to Salesforce

The AWS SDK for Salesforce makes it easy for developers to access Amazon Web Services in their Apex code, and build robust applications and software using services like Amazon S3, Amazon EC2, etc. You can get started in minutes by [installing the package](installing the package).

Amazon Simple Storage Service (S3) SDK

S3 is storage for the Internet. The Apex client gives you a kind of proxy for manipulating both buckets and contents. You can create and destroy objects, and presign a download URL, given the bucket name and the object key.

Sign up then go to your AWS Console > Security Credentials > Access Keys:
String access = 'XXXXXXXXXXXXXXXXXXXX';
String secret = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY';
AwsSdk.Connector connector = new AwsSdk.Connector(access, secret);
Creating a bucket:
AwsSdk.S3 s3 = connector.s3(region);
String name = 'thebucket';
s3.createBucket(name);

If redirect from AWS, it is possibile to specify the base AWS url:
AwsSdk.S3 s3 = connector.s3(region, 's3.us-east-1.amazonaws.com');
Adding an object to a bucket:
AwsSdk.S3.Bucket bucket = connector.s3(region).bucket('thebucket');
Map<String,String> headers = new Map<String,String>{'Content-Type' => 'text/plain'};
bucket.createContent('foo.txt', headers, Blob.valueOf('bar'));
Viewing an object:
AwsSdk.S3.Content content = connector.s3(region).bucket('thebucket').content('foo.txt');
HttpRequest request = content.presign();
String url = request.getEndpoint();

Amazon Elastic Cloud Compute (EC2) SDK

EC2 provides scalable computing capacity in the cloud. The Apex client calls services to launch instances, terminate instances, etc. The API responds synchronously, but bear in mind that the the instance state transitions take time.

Describing running instances:
AwsSdk.Ec2 ec2 = new AwsSdk.Connector(access, secret).ec2(region);
AwsSdk.Ec2.DescribeInstancesRequest request = new AwsSdk.Ec2.DescribeInstancesRequest();
ec2.describeInstances(request);
Launching a new instance:
AwsSdk.Ec2.RunInstancesRequest request = new AwsSdk.Ec2.RunInstancesRequest();
request.imageId = 'ami-08111162'; //amazon linux machine image
ec2.runInstances(request);
Terminating an existing instance:
AwsSdk.Ec2.TerminateInstancesRequest request = new AwsSdk.Ec2.TerminateInstancesRequest();
request.InstanceId = new List<String>{'i-aaaabbbb'};
ec2.terminateInstances(request);

Salesforce design considerations

When interacting with the AWS offerings, we encounter a few variations: signature vs transport, request vs response formats, REST vs SOAP oriented, etc. To maximize developer confidence, we use strongly typed DTO for request and response where appropriate. As the API footprint increases to consume more services, you can lean on a few utilities:

Where supported, we use region-agnostic API endpoints to avoid proliferation of Remote Site Settings. It would be prudent to store your access keys and secret credentials in a Protected Custom Setting.

aws-sdk's People

Contributors

bigassforce avatar fracarma avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.